How much swap space for a 32 GB RAM system?

Arthur Chance freebsd at
Wed Jul 23 07:45:42 UTC 2014

On 23/07/2014 03:32, Warren Block wrote:
> On Tue, 22 Jul 2014, RW wrote:
>> On Tue, 22 Jul 2014 10:24:13 -0600 (MDT)
>> Warren Block wrote:
>>> On Tue, 22 Jul 2014, Arthur Chance wrote:
>>>> I'm getting a new machine with 32 GB of memory. The old "twice
>>>> physical memory" sizing seems ridiculous, so how big should I make
>>>> swap? Do I even need swap with this much memory?
>>> Technically, no, but the system does like to have at least a little
>>> swap space and can benefit from it.  (I forget where this is
>>> explained, tuning(7) maybe.)
>> This is something that is often repeated, but I don't recall every
>> seeing an actual explanation.
> That's what I said, and then somebody pointed to the explanation.  But
> it was years ago, so now it's hard to remember exactly where it was.

As it was me that asked the question I thought I'd better go and look at 
tuning(7). This says, amongst much else

> The swap partition should typically be approximately 2x the size of main
> memory for systems with less than 4GB of RAM, or approximately equal to
> the size of main memory if you have more.  Keep in mind future memory
> expansion when sizing the swap partition.  Configuring too little swap
> can lead to inefficiencies in the VM page scanning code as well as create
> issues later on if you add more memory to your machine.  On larger sys‐
> tems with multiple SCSI disks (or multiple IDE disks operating on differ‐
> ent controllers), configure swap on each drive.  The swap partitions on
> the drives should be approximately the same size.  The kernel can handle
> arbitrary sizes but internal data structures scale to 4 times the largest
> swap partition.  Keeping the swap partitions near the same size will
> allow the kernel to optimally stripe swap space across the N disks.  Do
> not worry about overdoing it a little, swap space is the saving grace of
> UNIX and even if you do not normally use much swap, it can give you more
> time to recover from a runaway program before being forced to reboot.

Somehow this section feels like it was written a while back. (As do 
several other parts of the page.) The date on the man page is December 
8th 2012, but there's a lot of information in there about sysctl tuning 
that's liable to have been edited after the swap sizing section.

More information about the freebsd-questions mailing list