How to clear memory cache of Linux server?

 By default, every Linux OS has an efficient memory management system used to clear the buffer cache periodically. Many times systems faced low memory issues of Linux systems running a while. The reason is that Linux uses so much memory for disk cache is because the RAM is wasted if it isn’t used. Cache is used to keep data to use frequently by the operating system. Reading data from cache if 1000’s time faster than reading data from hard drive.

It’s good for the OS to get data from the cache in memory. But if any data not found in the cache, it reads from hard disk. So it’s no problem to flush cache memory. This article has details about how to Flush Memory Cache on Linux Server.


Every Linux System has three options to clear cache without interrupting any processes or services.

Firstly, check on the current usage, by type below command:-
free -m

Once done, you may choose which options you would like to use.
1. Clear PageCache only
echo 1 > /proc/sys/vm/drop_caches

2. Clear dentries and inodes
echo 2 > /proc/sys/vm/drop_caches

3. Clear PageCache, dentries and inodes
echo 3 > /proc/sys/vm/drop_caches


Comments