[clug] to swap or not to swap that is the question

Martijn van Oosterhout kleptog at svana.org
Wed Jun 30 00:54:35 GMT 2004


On Wed, Jun 30, 2004 at 09:54:21AM +1000, Martin Pool wrote:
> Suppose you start a program at bootup that allocates and writes to 4MB
> of memory, and then never touches it again.  In fact, suppose the
> process sleeps and never runs again at all.  With no swap space, that
> memory has to stay in RAM, using up space that could be used for disk
> cache, holding programs, or other data.  With swap, the kernel can
> write it to swap in the background, and never need to read it back in.
> So the cost is very small and it frees up memory.
> 
> Obviously you don't have a program which does exactly that, but you
> probably do have some few pages like that.  So allocate a bit of swap
> and let the kernel do its thing.

Actually, that's the reason I allocate about 64MB (or even 16MB on some
machines) of swap, nowhere near the actual amount of RAM I have. Just
to allow the kernel to get rid of some of those pages that never get
used again but it can't throw out. It's small enough that reading it
all in wouldn't take much time. If my machine starts swapping
constantly I need more memory. Fortunatly that doesn't happen...

This idea of scaling swap according to the amount of physical RAM you
have always seemed a little odd to me...
-- 
Martijn van Oosterhout   <kleptog at svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://lists.samba.org/archive/linux/attachments/20040630/c4232ff5/attachment.bin


More information about the linux mailing list