Since 2003 my system has a linux based SO… and I’m very happy… I took a quick peek at Windows 8 and I’m glad I don’t need it.
But it’s not always a bed of roses.
I got 8Gb of ram in my workstation but sometimes (lot of browser tabs, netbeans, virtualbox, etc) I run out of free ram. The kernel then start to use the swap file. And up to this time it’s all by the book.
It happens, often, to reach quota 6/7Gb but not over that… in these cases the kernel decide to swapout something and I find myself with about 2Gb of free ram and 1.5Gb of swap file… the problem is that at this point my user experience become tiring.
So I found that the problem regards a certain kernel parameter: vm.swappiness. In Ubuntu it’s default is 60 and the valid range is 0 to 100 (0 means “try to not swap unless is necessary”, 100 “swap whenere you feel like it”). To find out your actual value try this in a command shell:
cat /proc/sys/vm/swappiness
Now… if you want to try a new value you can launch this command:
sudo sysctl vm.swappiness=30
Once you found the right value for you it’s possible to put this setting in the configuration file “/etc/sysctl.conf”:
# swap tendency vm.swappiness = 10
To check your configuration you can use this command and watch “si” and “so” columns (“swapin” & “swapout”):
vmstat 1