Thursday, August 4, 2011

Clearing kernel cache in linux

This is about the drop_caches tunability. It's available in kernel 2.6.16 and above, and exists in /proc/sys/vm.

If you echo various values to it, various kernel cache data structures are dropped. This is a non-destructive operation, so if you still see stuff hanging out after it, it's likely that it was dirty cache. Anyhow, on to the values:

1 - drop the pagecache

2 - drop the dentry and inode caches

3 - drop both the dentry and inode caches, as well as the pagecache.

echo 3 > /proc/sys/vm/drop_caches as a root or admin user