Thursday, September 5, 2013

How to flush your swap on Unix machines

After your computer has been running for some time you may find that some memory is stuck living in swap while your RAM has space readily available. The data in your swap will be accessed much slower than if it was living in proper RAM space and it may be to your advantage to force it to RAM. I use the following to clean out the swap on my Ubuntu 12.04 workstation.
sudo swapoff -a && sudo swapon -a
Of course, if you are running as root you can omit sudo from the above command.

Plenty of room to move the swap in to.


Swap has been flushed to RAM.