Emptying the buffers cache
If you ever want to empty them you can use this chain of commands.
$ free && sync && echo 3 > /proc/sys/vm/drop_caches && free
total used free shared buffers cached
Mem: 1018916 980832 38084 0 46924 355764
-/+ buffers/cache: 578144 440772
Swap: 2064376 128 2064248
total used free shared buffers cached
Mem: 1018916 685008 333908 0 224 108252
-/+ buffers/cache: 576532 442384
Swap: 2064376 128 2064248
You can signal the Linux Kernel to drop various aspects of cached items by changing the numeric argument to the above command.
NOTE: clean up memory of unnecessary things (Kernel 2.6.16 or newer). Always make sure to run sync first to flush useful things out to disk!!!
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
The above are meant to be run as root. If you're trying to do them using sudo then you'll need to change the syntax slightly to something like these:
$ sudo sh -c 'echo 1 >/proc/sys/vm/drop_caches'
$ sudo sh -c 'echo 2 >/proc/sys/vm/drop_caches'
$ sudo sh -c 'echo 3 >/proc/sys/vm/drop_caches'