Is swap an anachronism?

Don't confuse (the) swap (as a disk area) and (to) swap (as a method to move memory pages from RAM to disk and reciprocally).

Excessive swapping is something to be avoided for performance reasons but having a swap area isn't necessarily a problem.

On systems, like Linux, that overcommit memory, i.e. that allow processes to allocate more memory than available, running out of RAM with not enough swap to handle the situation will trigger the OOM killer. You have to trust the algorithm used to select the "right" process to kill, and accept one or more of your processes to be killed without being given a chance to shut down properly. Here is a famous analogy that explain why the OOM killer might not be a good idea at all.

On systems like Solaris, that do not overcommit memory, i.e that make sure a memory reservation is always backed by virtual memory, whether in RAM or on disk, having a sufficient swap area is absolutely necessary otherwise a potentially significant part of the RAM will be wasted.


There's one very nice application for swap space: RAM extension by putting the swap space on storage device that uses RAM, to overcome limitations of installable system RAM

Have a look at this gadgest http://techreport.com/articles.x/16255 It basically a interface from S-ATA to DDR2-RAM. You can stuff up to 64GB of RAM into those. By placing swap space on one of those you're getting some significant additional RAM. Of course it's not as fast as regular system RAM. But it kind of turns the system RAM into sort of an additional cache layer.


I can't add to the discussion technically, but I can give a few examples. My old notebook (2GB RAM kunbuntu lucid) typically runs with swap at 0. When I run transmission (bittorrent client) with a number of torrents that can collectively be using 100 connections, my swap can go way up. It gets even worse when I have an XP vm running that uses 1GB real memory.

I have seen others comment that memory intensive processes like graphics rendering can also dip into swap. If you only do that occasionally, then it's not a issue.

As far as OOM problems, swap can actually be a lifesaver because it buys you time between identifying the problem and things going south. Lots of things use almost all my memory, so I don't pay any attention to that, but when swap starts running up I notice that and start looking for the problem - before it bites me.

Tags:

Swap