How to flush memory cache on linux

People often wonder what their linux box is doing with all their ram.. Generally it’s caching data on-disk, and will relinquish this cache when some other use for the memory comes around. If you wish to purge this cache, however, it’s relatively simple to do so:


sync; echo 3 > /proc/sys/vm/drop_caches

Should take care of it.