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

When I go to the system monitor in Ubuntu, about 75% of the Memory is used and 45% of Swap is used. Why is the Swap used even when Memory is available? Doesn't Linux move data from Swap to Memory?

share|improve this question
up vote 2 down vote accepted

It can move it to the memory. In fact, you can disable swap entirely, OR set a "limit".
This is the so called "swappiness".


How to check yours: cat /proc/sys/vm/swappiness
sysctl -n vm.swappiness

How to set this value: echo "10" > /proc/sys/vm/swappiness

The more Swappiness you set, the more the kernel will swap. So set it a LOW amount if you want to use your swap only when it is needed.

(Note: When you set the limit, you have to be root!)

share|improve this answer

Linux likes to keep data in both swap and cached in memory at the same time when the memory is available. If you look in the right place, you'll find that most, if not all, of the "swapped-out" data is also cached in main memory.

Why? Idle RAM doesn't provide any benefit, but, by keeping the swap cached, the kernel gains a lot of flexibility:

  • Is more real memory needed? OK, just reallocate the cached block. It's already stored in swap, so there's to need to write it to disk first.

  • Is the swapped-out block needed? OK, it's already cached in memory, so we can just change the cached copy's state from "cached" to "active" and invalidate the swapped copy without needing to touch the disk at all.

share|improve this answer

Why would the system move data from swap to memory if that data hasn't been accessed and may never be accessed? That would require pointless disk I/O and waste physical memory.

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.