linux drop_caches

drop_caches

/proc/sys/vm/drop_caches (since Linux 2.6.16)

Writing to this file causes the kernel to drop clean caches, dentries, and inodes from memory, causing that memory to become free.  This can be useful for memory management testing and performing reproducible filesystem benchmarks.  Because  writing to this file causes the benefits of caching to be lost, it can degrade overall system performance.

To free pagecache, use:

  echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes, use:

  echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes, use:

  echo 3 > /proc/sys/vm/drop_caches

Because writing to this file is a nondestructive operation and dirty objects are not freeable, the user should run sync(1) first.