Linux kernel can use swap even if there is enough free RAM.
This behaviour can be configured by setting the value of /proc/sys/vm/swappiness . The default value is 60, setting it to 0 means “never use swap when there is still RAM left“ and 100 is swapping out memory as soon as possible.
To change the value temporarily (lost on reboot):
sudo sysctl vm.swappiness=10
To change the value permanently: Edit the file /etc/sysctl.conf as root (e.g. sudo nano /etc/sysctl.conf ) and change the line vm.swapiness=... to the desired value.
There has been some debate on whether swapping out with free memory available is good or bad, but the Ubuntu help does indeed recommend a value of 10 for Desktop systems: https://help.ubuntu.com/community/SwapFaq
|