Linux performance tuning – /proc/sys/vm/drop_caches

Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache...
To use /proc/sys/vm/drop_caches, just echo a number to it.
To free pagecache:

[root@host]# echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

[root@host]# echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

[root@host]# echo 3 > /proc/sys/vm/drop_caches

This is a non-destructive operation and will only free things that are completely unused. Dirty objects will continue to be in use until written out to disk and are not freeable. If you run "sync" first to flush them out to disk, these drop operations will tend to free more memory.


  1. Be careful doing this. While it SHOULD be non-destructive, when I was playing around with this to free up memory to allocate for huge pages on a production Oracle DB server I had an unexpected/unplanned reboot. Fortunately it was during a planned maintenance window, so I didn't have to update my resume. I'm not sure if the reboot was a kernel issue, or if it was an Oracle reaction to the cache dropping (it was many moons ago, so my memories are a bit blurred).

    Also realize that all kinds of stuff that you had cached in memory will have to be re-read from disk the next time you need to access it, so you might take a performance hit.

    1. Is their any similar command for Windows System Please..

    2. I am not aware of one, but I don't really deal with WIndows, sorry.