I noticed this after a very long time, on my laptop today…thought I’d just blog up what to do about it
krish@shenron:~$ free
total used free shared buffers cached
Mem: 5717368 1556752 4160616 0 32116 295768
-/+ buffers/cache: 1228868 4488500
Swap: 4296696 156708 4139988
So, that’s pretty much more than 2/3 rds of RAM available, but the swap is being used already.
This setting is controlled by ‘vm.swappiness’
krish@shenron:~$ sysctl -A | grep "vm.swappiness"
vm.swappiness = 60
or you could find the value in
krish@shenron:~$ cat /proc/sys/vm/swappiness
60
The default value is 60.
A value of 0 means “never use swap till RAM is available“ .
A value of 100 would mean “swap as soon as possible”.
Using 0 is bit hard on the machine
, let’s use a value of 10
krish@shenron:~$ sudo sysctl -w vm.swappiness=10
[sudo] password for krish:
vm.swappiness = 10
.
krish@shenron:~$ sudo sysctl -A | grep "vm.swappiness"
vm.swappiness = 10
This value is not persistent on reboot unless you write it to /etc/sysctl.conf