Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

When I use a lot of RAM (90-100%) then the laptop normally starts using SWAP so if I look in htop during that intense usage I see it's using 200MB of SWAP. But when I stop using the laptop (the computer is idle and running) the SWAP is still used, it's not cleared as the RAM is.

Why is that?

  • System: Ubuntu 11.04 64-bit
  • Laptop: Asus 1201n 2GiB RAM, 2GiB SWAP, 1.6 ghz dual core cpu.
share|improve this question
I think it's normal it takes a long time before the SWAP space is freed. I get the same beheaviour here. – RobinJ Dec 22 '11 at 22:14
@Robinj it doesn't take long time, it doesn't happen. – Alvar Dec 22 '11 at 22:15
up vote 5 down vote accepted

The swap space will not move the swapped out pages back into the physical RAM until the processes that are using that memory access it again. So, especially if you are letting the computer idle, you will most likely never see all the swap emptied. There are two ways to clear the swap:

  1. Disable swap. During this process, the pages will be flushed back to RAM. Then you can re-enable it.
  2. Force every idle process to actively make use of whatever was swapped out.

Number 2 is nearly impossible, and number one is unnecessary. So, since whatever was swapped out is not even trying to use whatever is stored in that memory, I would not worry about having some swap usage - it is completely normal and will not affect your performance since the swap is not being actively "used".

share|improve this answer
I had the same idea on number 2 but I wasn't totally certain it was correct. But thanks! :) – Alvar Dec 22 '11 at 22:29

Linux tries to use your RAM as efficiently as possible. There's no point in bringing things back from swap if they aren't needed (although when they are, you'll have to wait a bit). It's more efficient to use that RAM for something useful, like caching files you are using on the hard drive.

share|improve this answer

Swap space need not be cleared until that space is again needed. At that time swap space will be relinquished to meet the new swap requirements according to predetermined criteria like when last used and assigned priority.

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.