Tag: Swap Space
Tell Ubuntu to avoid using SWAP partition with swappiness setting
by Craig Mayhew on Oct.14, 2009, under Guides/Fixes, Linux/Ubuntu
By Default Ubuntu will move data in RAM onto the swap file/partition on the hard disk long before it runs out of memory. It will pick data that isn’t accessed often but this can still be an annoying slow down on the system. To prevent the over use of SWAP space and speed things up all we need to do is change one setting… swappiness.
Swappiness can be set from 0 to 100. The default is 60 and the lower it is the more the computer will try to keep everything in RAM.
If you want to temporarily change the swappiness then run this command with desired swappiness level:
sudo sysctl vm.swappiness=10
Alternatively if you want the change to be permanent then edit this file:
sudo gedit /etc/sysctl.conf
Set swappiness to the desired level (in this case 1) by either modifying this line in the file “/etc/sysctl.conf” or if it doesn’t exist, add it at the end.
vm.swappiness=1
Reboot the computer for the change to take effect.
Ubuntu 9.06: Load used swap space back into RAM
by Craig Mayhew on Jul.13, 2009, under Linux/Ubuntu
When I have too many applications open or one of them eats all the memory I end up with a big chunk of my swap space used. The problem is that once I’ve closed a few programs or killed the offending program my computer still uses the swap space! I’ve read that the swap space will slowly be loaded back into RAM but only when it is next accessed. This results in sluggish system performance when the applications next read the memory in the swap space. To solve this problem you can empty the swap space and load it all back into RAM with one simple command. Please make sure you have enough RAM installed to load the memory in swap back into RAM…
This switches off swap memory and forces the system to load it back into RAM:
sudo swapoff -a
This switches swap back on incase you run out of RAM in the future:
sudo swapon -a
So now I can run those two commands, have the computer busy for 10-15 seconds and then know that it won’t slow down again due to needing to access the swap (Unless it runs out of RAM again).