Clearing Memory Cache with Linux

Linux is usually pretty good at efficient memory management notably with freeing up cached memory.  At times when an application(s) is abusing your system, Linux may decide that cached memory is needed when in fact it’s not.  This in turn can and will eventually rob your server of free memory.  A way to combat this is to run this simple command:

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

If you need to do this on a scheduled basis, you can turn the above line into a script, and create a cron job for it.  It’s a bad sign if  apps or system functions are hogging up free memory when it doesn’t need it, so it’d be better to investigate and troubleshoot that aspect of your system, rather than blindly clearing the memory cache of a system.

Advertisements