Clean up swap memory

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?


You could do this with the following:

swapoff /dev/sda2
swapon /dev/sda2

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

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


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.