how to drop linux disk caches

to instantly release buffer anc cache memory do:

echo 1 > /proc/sys/vm/drop_caches

using sudo (to handle the indirection):

sudo /bin/sh -c 'echo 1 > /proc/sys/vm/drop_caches'
  1. use free(1) to compare before and after.

  2. to free dentries and inodes, do echo 2.

  3. to free page, dentry, and inode caches, do echo 3