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 am using ubuntu 10.10. My RAM is 3GB and swap memory is 2GB. After using my system for several hours, all of my swap memory is used up. Is there any way so I can clean up swap memory?

share|improve this question
Is there a specific problem this is causing, or do you just hate the numbers? – Ignacio Vazquez-Abrams Apr 17 '11 at 2:31
@abrams: my cpu usage goes to 100% frequently. i don't know what is the cause. so i am checking out everything to narrow the options – user Apr 17 '11 at 2:35
That would not be caused by the swap. – Ignacio Vazquez-Abrams Apr 17 '11 at 2:39
up vote 5 down vote accepted

You could literally do this with the following:

swapoff /dev/sda2
swapon /dev/sda2

(assuming that /dev/sda2 is the location of your swap partition).

Not sure what the effect would be on system performance though while all swapped pages are moved back into physical RAM.

share|improve this answer
This is not a solution. If something is using swap space, removing swap leave the process in the cold, wanting more memory. The answer is, as Majenko mentions - find the application using swap. In "normal" usage "free -h" should show swap with 0 bytes used. – Daniel Mar 5 '15 at 21:48

I'd recommend trying to track down what is using all the swap space...

Run top then press OoReturn (that's capital-o, lowercase-o)

That will order the listing by the amount of virtual memory space the processes are using. You can then see what it is that is consuming all your swap.

share|improve this answer
This is great. I often have problems of putting Ubuntu to hibernate, because the swap space is too loaded. Using this, I was able to track down the process, killed it and everythings works now. Thank you. – mpaepper Jan 16 '13 at 19:19

In newer versions, sudo swapoff -a and sudo swapon -a work instead.

share|improve this answer

You must log in to answer this question.

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