Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Why should the size of the swap partition be double of the RAM size?

Does the rule of 1.5 *memory= swap still apply in these days where systems can have32 GB of memory. Besides the fact that it is always bad for a system to start swapping.

share|improve this question
I like the question, but I voted to move it to SuperUser. –  Thom Smith Oct 2 '12 at 16:24
It is not always bad for a system to start swapping. It is bad to start reading from swap back. –  Michael Krelin - hacker Oct 2 '12 at 16:26
There is probably never a reason to have more than 4GB of swap space. My university has a machine with 64GB of ram and it has 8GB of swap. –  Wug Oct 2 '12 at 16:26
Are you running a server that might start an uncapped number of server threads or processes lying dormant for a long time? Is it a mail server? –  Dmitri Chubarov Oct 2 '12 at 16:28
add comment

migrated from stackoverflow.com Oct 2 '12 at 16:46

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Mokubai, Indrek, 8088, ChrisF, Doug Harris Oct 2 '12 at 20:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

Yes, there are reasons.

  • Most notably for linux desktop PCs, you'll find that you cannot do hibernation without any swap.

  • Servers with very diverse use might profit from using more memory for file system buffers and sending some unused processes to swap for that (like, for example, mailman processes on a not very frequented mailinglist). Keyword here is swappiness (link goes to askubuntu, but it mostly applies to linux in general).

share|improve this answer
So, for hibernation, we still need at least as much swap as active RAM right? –  terdon Oct 2 '12 at 16:57
With active meaning, the amount of ram you actually use. Not sure about buffers and caches, linux might be smart enough to free these first if swap isn't sufficient. –  Jonas Wielicki Oct 2 '12 at 17:29
Disk is insanely cheap compared to ram so you might as well go 1.5x and not risk any problems. If you can split the swap over multiple spindles, so much the better. Just because you have the swap doesn't mean you should use it, however: One access to disk will blow out of the water whatever nice performance you were getting from fast CPUs. –  Brian White Oct 2 '12 at 18:15
add comment

One more reason to have a big enough swap.partition - the /tmp folder. Most modern linux distributions create in-memory file system tmpfs to mount as /tmp. And this is really not a bad idea. When the total footprint of all currently running applications is less than the RAM you have then why not to get the benefit from having /tmp as fast as RAM?

share|improve this answer
There is some argument as to whether there is any benefit since /tmp on disk still benefits from ram caching of that filesystem. You may get better system performance by letting the kernel decide how to globally optimize the filesystem cache rather than you try to skew it towards /tmp. Also, sometimes /tmp files are large and can exceed swap. –  Brian White Oct 2 '12 at 18:14
@BrianWhite I agree on that, in all cases when you tune your system for performance you should take into consideration all factors and solutions out of the box are not always performing well. –  Serge Oct 2 '12 at 18:17
Also, at least one large distribution (Fedora) is not doing that. –  Jonas Wielicki Oct 2 '12 at 18:35
@JonasWielicki i am giving up –  Serge Oct 2 '12 at 18:38
add comment