[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Swap



I do not know where the various rules-of-thumb came from, but suspect it
mostly was from production multiuser/multiprocess systems where the
emphasis was on throughput, I/O wait was common, and it throughput could
be increased by overcommitting real memory and thereby reducing the
processor idle time that occurs because processes are waiting for I/O
completion.  The target model would be a zSeries mainframe or large Unix
or Windows server with many jobs running.

On a desktop system, probably with one and a small fraction users, not
all that many background processes, and, with present memory prices
being what they are, enough memory to hold them all, the swap
requirement is lower, and possibly zero.

In general, you do not really want to swap, ever, especially on an
interactive system.  Swapping (now usually paging, which is somewhat
different) always will degrade performance, and should be avoided if
possible.  That said, another poster noted that if hibernation is an
option, swap is where the memory image is put, and it should be at least
as large as real memory.

You can estimate the need for operational swap reasonably using
utilities like top and vmstat.  Top will show maximum swap for the
current boot at a glance; if it is zero, no swap has been used since the
last boot, and if the system has been up for a while that indicates a
zero (or at least small) swap requirement.  If the amount is not zero,
it would be reasonable to add half a GB or so to the peak swap and round
up to next full GB.  Bad things are likely if you run out of (memory +
swap).  If it is a laptop and you want to use hibernate, set swap to the
larger of the operational swap size and the system memory size.

Tom Dial

On 02/04/2016 08:42 AM, Jos Collin wrote:
> Hello,
> 
> How much swap space does 4GB ram ideally requires ? I have been using
> the rule "RAM size x 2" for calculating the size of swap. But as the RAM
> sizes are bigger nowadays, is this a wrong calculation ? I mean, is it
> okay if I use 1 GB of swap space (or lesser) for a 4gb RAM ?
> 
> (I use to suspend my system everyday by pressing  alt+shutdown menu in
> gnome 3)
> 
> Please suggest.
> 
> Thanks,
> Jos Collin
> 


Reply to: