sudo echo 3 | sudo tee /proc/sys/vm/drop_caches
this works ....
Just found this thread and command works great in 10.10 Maverick. Cache usage instantly dropped from 77% to 5% of 2Gb RAM.
Thanks for the tip
Thanks for the running as root suggestion!! (Works like a charm!)
Here is a screenshot of my sysmonitor! (It monitors RAM, I have a memory problem, not enough!)
Once again for those who didn't read the whole thread: clearing the cache is not a good thing. Caching files in memory that otherwise would be empty helps system performance. As soon as it is needed, it will be reallocated, but until then it may as well be put to good use.
To put it another way, cache memory is, for all intents and purposes, free memory, with a bonus side effect.
lol @ people upset that cache refills
There are actually two things you can clear, and they're both read caches. Write caching is a different thing entirely, and is referred to as 'dirty memory'. 1 is file data (contents), 2 is file metadata(time, date, permissions, names, etc), and 3 is both. So for example, if you do a 'find /' looking for a file, and then read a 1GB file, and want to evict the 1 GB of data, but not lose the cached 'find' info, you can echo 1.
man /proc and look for drop_caches for the exact details. None of this is Ubuntu specific, by the way.
I have ubuntu 9.10 server X86 setup with SMB shares as a headless media server in my basement network cabinet. It has been running 24/7 for about a year (with the exception of a few power outages from storms) and when it has been heavily used (in my case three computers streaming for a couple of hours) I notice that up to %30-47 of the memory will be cached (in this case checking from ssh remotely on network with no streaming occurring 20 minutes after peak activity). Streaming isn't negatively affected, but I will notice some "hesitation" when logging into the shares from a computer to browse to the file I wish to use after heavy multicomputer use of the shares. A reboot of the server clears the memory usage to normal (3% of 2 GB) and this is how I have dealt with it when it occurs.
Thanks so much to the OP and suggestions of others. A quick login via ssh, dropping to root and
has made it much quicker to restore the snappiness of my samba media server without having to restart it remotelyCode:sync; echo 3 > /proc/sys/vm/drop_caches
Last edited by waffletten; February 15th, 2011 at 04:06 AM.
I just wanted to add my 2 cents.
I woke up my laptop which I last night put to sleep and it had around 30% SWAP that's over 1GB.
I have only 2GB of memory. Computer was 'useless' (meaning it felt like the old WinXP - almost there... almost there).
I found Ubuntu clear swap info page and this page. I needed to clear my 1GB cache to fit swap back to ram. So after these two scripts I'm back in business! No restart needed.
I don't know if there is another way to do this. But at the moment I have 40% free memory with no swap. Feels low amount considering I only run FireFox, scribes and gnome-term or whatever.
I would really love to get some real info about memory usage in linux and ubuntu. Modern I mean. Since gwibber alone takes 25MB per each process coming to around 100MB all together !!!
Really! 100MB for MSN
UbuntuOne-sync also 30MB and nm-applet 30MB.
But these are ALL extra programs and I can shut them down if need to so can't complain. They got great usability.
But still would love to understand better about memory usage and need.