[PLUG] Ideal Swap partition size

श्रीधर नारायण दैठणकर ghodechhap at ghodechhap.net
Thu Mar 20 13:38:48 IST 2008


On Thursday 20 Mar 2008 12:10:14 Devendra Laulkar wrote:
> I would like to know the ideal swap partition size for new computers which
> typically come with > 1 Gigs of RAM.

It is not about size of swap but how much swap that is actively used. If the 
disk is thrashing, then one might as well reset the machine.

There are workloads that just push things beyong threshold. If I run a 512MB 
VM(opensolaris demands at least that much) and start a build of my day job 
project,  which takes 450MB, peak, things are usually ugly on a 1GB RAM  
machine.  It does not matter if machine has 64MB swap or 640MB.

OTOH, swap is there to be used. Unused swap, either literally unused or pushed 
to swap and not fetched back again, usually is useless.

So I would vote for 64-128MB swap. I can't think of any scenario where swap 
size an issue while machine is still usable.

> Personally, I never recommend a swap partition of more that 500-600 MB,
> because typically I have seen that swap partition is not utilized to that
> extent for typical home + development use. I feel that swap partition = 2
> * physical memory formula seems to be long outdated with current RAM
> sizes.

I agree. But there is other side to it. It comes from memory overcommit. On 
linux, 100MB malloc may return successfully but does not mean you can use 
100MB always. OOM killer could kill you in between, in case of crunch.

BSDs dont do that and hence recommend twice the amount of swap. But with 1GB 
RAM machine, even that is too much.

So turn off overcommit, and use swap small enough to be usable.

Shridhar




More information about the Plug-mail mailing list