Tuesday, April 9, 2013

Clearing memory cache

First thing you need is kernel 2.6.16
The command to clear the memory cache.

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

sync -> refers to the tells the kernel that you want the data written to the disk
echo 3 > /proc/sys/vm/drop_caches -> "To free pagecache, dentries and inodes:"

From the article Invalidating the Linux buffer cache ,

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

References:
  1. Invalidating the Linux buffer cache 
  2. HOWTO: Clear filesystem memory cache
  3. drop_caches

No comments: