Linked by David Adams on Thu 20th Nov 2008 04:19 UTC
General Unix Linux and other Unix-like operating systems use the term "swap" to describe both the act of moving memory pages between RAM and disk. It is common to use a whole partition of a hard disk for swapping. However, with the 2.6 Linux kernel, swap files are just as fast as swap partitions. Now, many admins (both Windows and Linux/UNIX) follow an old rule of thumb that your swap partition should be twice the size of your main system RAM. Let us say I’ve 32GB RAM, should I set swap space to 64 GB? Is 64 GB of swap space really required? How big should your Linux / UNIX swap space be?
Permalink for comment 337844
To read all comments associated with this story, please click here.
I don't use swap at all
by asgard on Thu 20th Nov 2008 09:55 UTC
Member since:

If I have a desktop machine with more than 1GB RAM, I usually put no swap space at all.

There is a big disadvantage of large swap - if you have a process that runs and eats too much of memory (for example, due to leak), system starts swapping, and everything is going to halt. If you make swap proportional to the size of the main memory, it will take proportional time before OOM killer kicks in and shoots down the process. This means a lot bigger and unnecessary wear of your hard drive.

For most Linux usage, 1GB of memory is sufficient. If you need more, just add more RAM, it will be more efficient to your time and hard disk wear. With larger amounts of RAM, the chances that swap will help you more than it will hurt you is diminishing (i.e. the probability that application will be save by additional 1GB is getting lower, but the probability that it will due to some bug eat any amount of memory you throw at it is the same). Sure, hibernate is a problem, but I don't use that (I use sleep).

What I would like to see would be if kernel could somehow notify applications that memory is running out, so the applications could help. For example, they could reduce their memory usage at the cost of CPU, run GC cycle, compact their memory, reset themselves to prevent any runaway leaks and so on.

Reply Score: 2