How to Flush Memory Cache on Linux Server

Many times Linux systems faced low memory issues,This article has details about how to Flush Memory Cache on Linux Server.There are three options available to flush cache of Linux memory. You can use one of below as per your requirements.

To free pagecache, dentries and inodes in cache memory use:

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

To free dentries and inodes use following command:

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

If to free pagecache only use following command:

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

You can also schedule following in crontab to automatically flush cache on regular basis.

crontab -e

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