Free cache and swap space on Linux

Free cache memory on Linux

Some times it is useful to free the cache memory on Linux systems, these simple commands are useful (they should be run as root).

To free pagecache:

# echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

# echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

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

Free swap memory

You can also free you swap memory with the following commands (again run them as root).

# swapoff -a
# swapon -a

About Steve Nash 32 Articles
M.D. and lead technical developer of BitSolver Limited, designing and developing high quality Bespoke Software and Websites for many businesses.