Saturday, November 3, 2012

Linux memory cache

Note: Linux is NOT "eating" your RAM! Please take a look at Geirha's excellent answer below to understand why...
After the above note, if you still feel "cleaning" the cache could help, you can certainly try: it's a one-liner from the terminal:
sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
There's no easy way to disable the cache, but you can achieve the same effect by cleaning it as often as every minute, if you want to:
  • Make it a cron-job
  • Press Alt-F2, type gksudo gedit /etc/crontab, and add this line near the bottom:
    */15 * * * * root sync && echo 3 > /proc/sys/vm/drop_caches
  • This cleans every 15 minutes. You can set to 1 or 5 minutes if you really want to by changing the first parameter to * or */5 instead of */15

One liner to know REAL free RAM, excepting cache

Geirha's answer explains the details, but in short, you get the number of free megabytes with:
free -m | sed -n -e '3p' | grep -Po "\d+$"
which on my 2GB command-line server returns an extremely health 1835.


http://askubuntu.com/questions/155768/how-do-i-clean-or-disable-the-memory-cache

http://www.linuxatemyram.com/

No comments:

Post a Comment