Linux – How to free virtual memory in Ubuntu

linuxmemoryUbuntuubuntu-9.10

Current statistics affirm that:

100Mb of RAM are used out of 312Mb and 31Mb of Virtual Mem are used too.


Anyway I can stop the OS from using virtual memory instead of RAM? I know that this happens when RAM becomes saturated, and OS has nowhere else to store data other than the hard disk.
But the Virtual mem doesn't seem to go down, instead it looks like it prefers staying there.


I'm not sure if this is a problem or not, as maybe it doesn't necessarily mean that the virtual mem is being used over the ram.

Help would be much appreciated! Thanks! 🙂

Best Answer

Check out your swappiness value in /proc/sys:

$ cat /proc/sys/vm/swappiness
60

You can force Ubuntu not to use swapfile until absolutely necessary by changing this value to zero:

$ sudo sysctl vm.swappiness=0
vm.swappiness = 0
Related Question