
SWAP-Tips
SWAP is an area on the disk that is part of the Virtual Memory. Called as an area on the disk because we allocate / create a special partition on the hard drive during installation of Linux. Swap handle memory pages that are inactive for a while. Swap will be used when the system has needed physical memory (RAM) to handle an active process but a physical memory (RAM) unused (free) is not sufficient. If the system requires more memory resources or space, the pages that are not active on the physical memory (RAM) will be moved to swap for to make room in physical memory (RAM) to handle other processes.
Due to disk (swap is on the hard drive) is slower than RAM, the response time for the system and the applications become slow if the case of a too large displacement of physical memory.
There are parameters for controlling propensity swappiness kernel to move the process from memory to the swap. Value between 0 -100, when swappiness=0 then it will tell the kernel to avoid swapping prosses (ram into the swap) as long as possible, while swappiness=100 then it will tell the kernel to perform the process swapping aggressively.
The default value in Ubuntu is 60 and is recommended to set swappiness=10 on Ubuntu Desktop Edition to improve overall system performance.
To check the value swappiness, open Terminal (Applications > Accessories > Terminal), then run the following command:
cat /proc/sys/vm/swappiness
To change the value swappiness=10 to temporarily run the command below, but only temporary (after restart will be back to normal)
sudo sysctl vm.swappiness=10
To change permanently:
gksudo gedit /etc/sysctl.conf
Find line vm.swappiness and change the value to 10. If no vm.swappiness line, add this line at the end:
vm.swappiness=10
Once done, Save and then restart your Ubuntu.