Swap Space

Matthew Seaman m.seaman at infracaninophile.co.uk
Thu Jan 6 09:42:49 UTC 2011

On 05/01/2011 22:33, Jeff Whitman wrote:
> I'm finding conflicting data on this.  Some say 0, some say 1 times RAM,
> others say stay with 2 x RAM.

Standard advice is 2x RAM -- but that dates back to the days when
servers would have quantities of RAM measured in Megabytes rather than

2 X RAM is a lot of disk space nowadays -- so either you'll need to find
some other use for that space; eg. as a swap-backed /tmp partition,
or else provide less swap.  Also, there's a maximum of -- I think -- 8GB
swap above which the performance of swap is degraded, due to algorithmic
limits in the way memory pages are mapped onto disk pages.

You need 1 x RAM + a few kB in order to support getting a crashdump. Or
at least, you did before the days of minidumps.  Not sure what the
requirements are for getting system dumps nowadays.  Swap space used for
crashdumps should be a raw partition, not a file.

On the other hand, for good performance you should not be using any
significant amounts of swap in normal usage.  You will need some swap,
as the OS tends to use a small amount even when not under memory
pressure.  You should have swap to act as a buffer in case your machine
suddenly starts using up more memory than you expect, either because of
memory leaks, or due to demand spikes or through any number of other
possible causes.

Therefore, I think the best advice for a modern large memory system
would be:

    If RAM > 8GB, then SWAP = 8GB[*]
    If RAM < 8GB, then SWAP = 1 x RAM + delta

where delta is perhaps a Megabyte or so.  Just rounding the partition
size up to the next cylinder boundary should be enough (which happens
automatically with most partitioning schemes).



[*] In this case, if you need crashdumps, you should dedicate another
otherwise unused partition of the correct size as your dumpdev.

Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
JID: matthew at infracaninophile.co.uk               Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20110106/4cd3eae8/signature.pgp

More information about the freebsd-questions mailing list