Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why is it recommended that the swap partition size be double that of the RAM size?

Specifically, why would I need to store data stored in the RAM twice??

share|improve this question
up vote 8 down vote accepted

Swap partition having double the memory size is just a general guideline, not a hard and fast rule. You'll need minimum 1 X your memory size if you suspend-to-disk (hibernation), and add enough spare for usage of 'swapped' memory which goes beyond your physical one. Hence the recommended 1.5 to 2 times.

I would think it also depends on the nature of your application usage and size of your physical memory etc. If you have anything beyond 2GB RAM and using non-memory intensive applications most of the time, you might not need swap partition at all, not big one anyway.

Having a big swap file and slow harddisk can be really punishing for your system too.

Here are a few useful reads:

Ubuntu SwapFAQ
SUperuser - Swap partition size for 4GB RAM
Do I Need a Swap Partition and If So, How Big?

share|improve this answer
Slow or not, it's always better to have a swap just in case, even if you don't need it, than risking running out of RAM with no swap available. – Don Feb 21 '10 at 10:52
@Don, yea I agree it is safer to have swap partition. :) – o.k.w Feb 21 '10 at 11:49

Specifically, why would I need to store data stored in the RAM twice??

The swop is simply for freeing up system memory. If you begin to run low on memory the system will free up memory by moving the least used data from memory onto the hard disk swap file. This of course has a speed penalty but it frees up memory for other applications.

With memory being so cheap you are always better off to have as much as you can afford. This way the swap gets very little access and your system stays nice and fast.

share|improve this answer

With a larger swap space, programs can use more RAM than is present on the computer. This is possible because even if the data takes up more space than fits in the physical memory at once, it cannot all be accessed at once - the swap is pulled into physical memory as it is needed. The alternative is to have programs randomly killed when memory runs out. This is particularly useful if you want to edit high resolution images or videos, or do 3d modeling or rendering, or run numerical analysis on large amounts of data, there are many kinds of programs that end up wanting insane amounts of RAM, where it is better to be able to have it run very slow than to have it unable to run at all without crashing.

share|improve this answer

That's an old rule of thumb, that I don't think makes sense anymore, because that may equate to an absurd amount of swap nowadays.

An indication of the amount of swap you should have, is how much you use: as a minimum, the steady-state swap usage after a fair bit of uptime; as a maximum, I would say the maximum usage under high memory use, plus some more just to be on the fair side. But I'm here to tell you that there's actually a reason not to be overly generous with the swap space:

In my experience, what happens when you run out of memory (such as when accidentally setting off a fork bomb like make -j) is this: First, you notice a bit laggy user interface, which means, you have roughly a minute to kill the offending process, before the mouse pointer becomes completely unresponsive. But that's only the start! You see, then, the computer is going to sit there with its SSD LED constantly lit, churning through the rest of its swap space, for tens of minutes to hours, while you can do nothing (except maybe pulling the plug). At this point, you are going to swear you wanted the OOM killer to kick in a bit sooner, instead of wasting your day.

So having a ridiculous amount of swap space that you don't normally use is actually bad from an availability standpoint — it just delays the inevitable in the event of a catastrophic memory leak (such that OOM is inevitable), during which time your computer is, for all practical purposes, unavailable.

I usually go for ½-2 GiB swap regardless of how much RAM the computer has.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.