Change the swappiness of your Ubuntu system
Change how frequently Ubuntu uses the swap
You can check the current swappiness value with:
To change it for the current session run:
sudo sysctl vm.swappiness=10
A value of 10 means that the swap will be utilized only after the RAM has reached 90% of its capacity.
To change it permanently edit
sudo nano /etc/sysctl.conf
vm.swappiness and change its value as desired. If
vm.swappiness does not exist, add it to the end of the file like so:
Save the file and reboot.