Thursday, November 6, 2008

freeing cache on linux with drop_caches

Linux kernel 2.6.16 and later has a option which let's you free inode/dentry and pagecache caches on your system. The file is located on /proc filesystem.
It has 3 options. For example:

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

frees pagecache on your system.

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

frees inodes and dentry caches

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

frees pagecache and inode/dentry caches.

tip: some dirty caches are not freeable so it's better to use "sync" command before using drop_caches for freeing much more memory on your linux system.

No comments: