Ubuntu – I have 16GB RAM. Do I need 32GB swap


I read many places that the rule of thumb for swap space is to double the amount of physical RAM. However, 32 GB does seem a LOT. Do I need that much? Do I need it at all with this high amount of physical RAM?

Best Answer

It entirely depends on what you plan to do with the machine. For example if it were a Sap server then yes, I would add 32gb swap ( we have boxes at work with 128gb ram and 32gb swap ). If you were manipulating massive pictures and video then it makes sense to have a little swap. 32gb is probably overkill.

However I would not say zero swap.

In the unlikely event that you run out of RAM - perhaps opening a big file, perheps a long running tab in firefox, it doesn't matter, in that event your kernel OOM killer will kick in and start killing applications to get memory back. Under those circumstances it's entirely possible that you will lose data as applications get killed. However if you have a bit of swap then the system will carry on, grabbing swap and allowing the system to continue. System slows down as heavy swapping happens, you notice and investigate before all swap exhausted. Also disk is very cheap, so why not have swap?

Anyone who says "you don't need swap" without asking you what you're actually doing with your computer is making assumptions. Whilst you may well do very little with your computer that eats RAM, it's still best to ask the questions about what you're planning to do with it before making the rash judgement that you don't "need" swap. In my humble opinion