Hello Makers, 👋

Cause :

Your sites run a lot of MySQL queries on the server. A LOT of MySQL queries will create a lot of RAM usage. Because the server decides to keep the commonly accessed data in the RAM instead of requesting it every single time. And you may have a cronjob set up to restart once a week.


Like any other operating system, GNU/Linux has implemented memory management efficiently and even more than that. But if any process is eating away your memory and you want to clear it, Linux provides a way to flush or clear ram cache.

If a Linux server appears to have inodes or dentries filling up cached memory, here is how you can flush it without putting the server through a reboot.

This will only work with Linux kernels equal to or greater than version 2.6.16+ which was introduced around late 2005.

1) Check available, used, cached memory with this command:

[[email protected]]# top -n1 | grep -i "used," ; free -t -m

Mem: 4035004k total, 1478408k used, 2556596k free, 225932k buffers

total used free shared buffers cached

Mem: 3940 1443 2496 0 220 659

-/+ buffers/cache: 563 3377

Swap: 5945 0 5945

Total: 9886 1443 8442

In this case, approximately 659MB is cached, in most cases it can reach gigabyte ranges on production servers. Follow step #2.

2) Commit any buffers to disk first with the following command:


[email protected]]# sync

[[email protected]]#

3) Next Let's send a signal now to the kernel to flush page caches, inodes, and dentries:

echo 3 > /proc/sys/vm/drop_caches

[[email protected]]# echo 3 > /proc/sys/vm/drop_caches 

[[email protected]]#

4) Check system RAM again

[[email protected]]# top -n1 | grep -i "used," ; free -t -m

Mem: 4035004k total, 563996k used, 3471008k free, 1224k buffers

Swap: 6088624k total, 156k used, 6088468k free, 35912k cached

total used free shared buffers cached

Mem: 3940 550 3389 0 1 35

-/+ buffers/cache: 514 3425

Swap: 5945 0 5945

Total: 9886 550 9335

We have now cleared cached memory and freed up several hundred MB without a server reboot. If you still have any questions, please feel to contact us!

Happy Making!

Did this answer your question?