Clear RAM Memory Cache, Buffer & Swap Space

GNU Linux has implemented efficient memory management algorithms & tools which gives you the power & flexibility to control both the physical & virtual memory on your system.

Clear Cache

There are 3 options to clear cache without interrupting any processes or services:

  • Clear page cache:

    # echo 1 > /proc/sys/vm/drop_cache
    
  • Clear dentries and inodes

    # echo 2 > /proc/sys/vm/drop_cache
    
  • Clear PageCache, dentries and inodes

    # echo 3 > /proc/sys/vm/drop_cache
    

Clear Swap Space

  • Clearing swap space is as easy as disabling & re-enabling the devices/files used for swaping.

    # swapoff -a && swapon -a
    

Further Reading

  1. What is a Superblock, Inode, Dentry and a File?