Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I have a KVM host running several virtual machines. The hardware is comprised of 24 cores w/ 40G of ram. This is the output of the free command:

                     total      used       free     shared  buffers  cached 
Mem:                 41180500   32340344   8840156       0  2126008  36480
-/+ buffers/cache:   30177856   11002644 
Swap:                3903484    3511516    391968

Why is the system swapping if it still has a lot of free RAM? Occupation has never been above 80% (nagios never reported more than that amount). And given that 20% of the RAM is 8G, it's still much more than the available swap (which is 4G).

share|improve this question

migrated from Jun 21 '13 at 11:57

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

up vote 3 down vote accepted

Take a look at this article. It explains the problem, provides solution and some quick benchmarks. In short some settings that should improved the situation are:


Explanation of what they are and what they do can be found in the article.

share|improve this answer

You could try changing your "swappiness" value.

Here is a howto link:

share|improve this answer

To stop the kernel swap memory you can change vm.swappiness to 0. This stops the kernel using virtual memory. You can also use the function mlock() to stop your application from being swapped.

share|improve this answer

On modern systems, swap will usually remain unused. Processes which are long-running are shifted to swap by the kernel. Some programs start working slowly because of that. You said you have ram free, so you could disable swap by running the command: swapoff -av (prefixed by sudo if you're not root)

If you don't like the swap off, you may enable it, using reverse command: swapon -av (again with sudo if necessary).

share|improve this answer
Changing swappiness as described in other answers is a much better approach, since it can handle out-of-memory problems when you DO manage to use more memory – nealmcb Dec 28 '13 at 1:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .