Tuesday, 31 January 2012

How to release the Linux disk buffer/cache

Inorder to free the disk cache we get an interface /proc/sys/vm/drop_caches has been available to simplify this process.

First we run the sync command before dropping the cache. Doing this will ensure that all memory in the cache is updated and all dirty pages are synchronized before dropping the cache.

You can safely skip this step but if you have any dirty pages in your disk cache the system will refuse to release them.

# sync

next step is echoing “3″ to the /proc/sys/vm/drop_caches file which will signal the OS to release the pagecache, dentries and inodes.

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

# sync

# echo 0 > /proc/sys/vm/drop_caches ----- default value/ after clear the cache make it as 0 by running this command.

# echo 1 > /proc/sys/vm/drop_caches ---- only page cache

# echo 2 > /proc/sys/vm/drop_caches ------ only inode 

# echo 3 > /proc/sys/vm/drop_caches --- inode/page cache/clear all cache

No comments:

Post a Comment