# cat /proc/sys/vm/swappiness
A swappiness setting to 0 means that the disk will be avoided unless absolutely necessary (when you are running out of memory), so even if you have swappiness set to 0, you could still see some swapping happening. A swappiness setting of 10 means that programs will be swapped to disk almost instantly.
To change the value of swappiness:
# echo 0 > /proc/sys/vm/swappiness
To change it permanently:
# vi /etc/sysctl.confadd the following
vm.swappiness=0
Which process is swapping?
To find out which process is swapping, run the "top" command then press "O" followed by "p" then "Enter". Processes will be sorted by swap usage.
One thing you should know that it is not possible to get the exact size of used swap space of a process. Top fakes this information by making SWAP = VIRT - RES, but this is not a good metric, because other things such as video memory counts on VIRT as well.
Here is a script to check what is consuming your swap:
check-swap.sh
Clear swap:
You can also clear your swap by running "swapoff -a" and then "swapon -a" as root instead of rebooting to achieve the same effect.
No comments:
Post a Comment