Previous Post: How to mount and unmount a drive in linux
Next Post: Web-safe fonts for linux viewers
Feb 28, 2008 at 10:17 pm - 4 Comments
Linux has a supposable good memory management feature that will use up any "extra" RAM you have to cache stuff. This section of the memory being used is SUPPOSED to be freely available to be taken over by any other process that actually needs it, but unfortunately my linux (two distros now, mandriva i586, and mandriva x86_64) thinks that cache memory is too important to move over for anything else that actually needs it.
I have 6 GB of good RAM in my computer. Whenever there is no disc cache being stored in the memory (ie, when i first boot the computer), everything runs great. I mean, really great. But as soon as it fills up with cache, my computer starts feeling like a 700mhz pentium 2 with windows 98 full of viruses. Its terrible.. So terrible that I almost, ALMOST, consider going back to windows (ok, maybe not)
Up until just now, I have been forced to restart every time this happens because I simply cannot get any work done while in this state of retardation. I can close every single program I'm running - and even then, simply right clicking would require some extended thinking before loading the context menu. Ridiculous.
Luckily, I found a way to clear out the cache being used. Simply run the following command as superuser (root) and watch the memory cache usage disappear.
sync; echo 3 > /proc/sys/vm/drop_caches
Thanks to ariel for posting in the comments about including the sync command before dropping caches.

James - Sep 15, 2008
You rock. This just saved me a reboot. The last of which took the machine down for a day because of the stupid journalized drive.
Thanks
B K - Apr 06, 2008
"Linux: How to clear the cache from memory".
U have 6 GB RAM?? then the matter is really terrible. Even the ISP servers hosted on Redhat Enterprise Linux rock on 2GB. Go for optimization of code basics. Gerhard Mourani's "securing and opimizing redhat linux edition" is a good ebook.
Nat - Mar 01, 2008
Check 'swapiness'
ariel - Feb 29, 2008
Hello Scott, i found that you should run "sync" before writing to drop_cache.
Source: http://www.linuxinsight.com/proc_sys_vm_drop_caches.html