Skip to content

Posts tagged ‘Clear cache’

30
May

Free Up Cache Memory in Ubuntu

Ever wondered how to remove the cache memory in Ubuntu? Linux kernels 2.6.16 and newer provide a mechanism to clear the inode, page, and dentry caches on demand. All you have to do is echo a value to the proc filesystem, and you’re done. Follow the recipe below:

As this is a non-destructive operation and dirty objects are not freeable, run:
sync

To free pagecache:
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches"

To free dentries and inodes:
sudo sh -c "echo 2 > /proc/sys/vm/drop_caches"

To free pagecache, dentries and inodes:
sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"

Hope this works for you all.