How do I free virtual memory in Ubuntu?

10,706

Solution 1

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

Solution 2

You can clear out the swap by using these two commands in order:

sudo swapoff -a
sudo swapon -a
Share:
10,706

Related videos on Youtube

RadiantHex
Author by

RadiantHex

hello! :)

Updated on September 17, 2022

Comments

  • RadiantHex
    RadiantHex over 1 year

    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! :)

  • Nicklas
    Nicklas about 14 years
    This clears the swap, but doesn't prevent anything from immediately reclaiming it. Also, it can be a Very Bad Idea if there isn't enough space to write the swap back out.
  • RadiantHex
    RadiantHex about 14 years
    isn't the Virtual Mem usage => SWAP usage ?