As we know, swap is the area on a hard disk as part of the Virtual Memory. Swap temporarily holds memory pages that are inactive. Swap space is used when your system decides that it needs physical memory(RAM) for active processes and there is insufficient unused physical memory available. If the system happens to need more memory resources or space, inactive pages in physical memory are then moved to the swap space therefore freeing up that physical memory for other uses.

Because disks are much slower than RAM, this can lead to slower response times for system and applications if processes are too aggressively moved out of memory. So we can control the usage of swap area to speed up Ubuntu if there’s a large enough RAM.

There’s a swappiness parameter controls the tendency of the kernel to move processes out of physical memory and onto the swap disk. It ranges from 0 to 100, and when swappiness=0 it tells the kernel to avoid swapping processes out of physical memory for as long as possible, when swappiness=100 it tells the kernel to aggressively swap processes out of physical memory and move them to swap cache.

The default value of swappiness in Ubuntu is 60, and it recommends swappiness=10 for Ubuntu Desktop to improve overall performance.

First, check the value of swappiness in Applications -> Accessories -> Terminal with this command:

cat /proc/sys/vm/swappiness

Temporarily change swappiness’ value to 10 using following command, and it will be reverted in next restart.

sudo sysctl vm.swappiness=10

To permanently change this value, using:

gksudo gedit /etc/sysctl.conf

Search for vm.swappiness and change its value as desired. If vm.swappiness does not exist, add it to the end of the file like so:


Finally, save the file and reboot.