Friday, December 5, 2008

/proc/sys/vm/drop_caches

what exactly is the purpose of /proc/sys/vm/drop_caches file ?

can any one give a practical situation where the tip given in the following how to is used ?

In the past, I've been forced to do ridiculous things like cat a file larger than available RAM to /dev/null and edit gigabyte files which flood my cache with this data. Luckily, Linux kernels 2.6.16 and newer provide a mechanism to clear the inode, page, and dentry caches on demand avoiding all this headache. All you have to do is echo a value to the proc filesystem, and you're done.

To use /proc/sys/vm/drop_caches, just echo a number to it.

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

As this is a non-destructive operation and dirty objects are not freeable, the user should run "sync" first!

This was originally found @ http://www.linuxinsight.com/proc_sys_vm_drop_caches.html


ilikejam

The only time I've ever seen anyone use this is when doing I/O benchmarking - dropping the caches forces disk operations to happen on the disk instead of in RAM.

No comments:

Post a Comment