Monday, January 2, 2012

Almost Out of Memory?

August being the last time I posted anything, I'm going to ease back into this by being brief. Today I learned something interesting and thought I'd share. I was checking my RAM usage on my server using the top command and I thought it very strange that on a system with 48GB of RAM I had only about 3GB free while the server wasn't hardly busy at all. I quickly found the free command which is another tool to monitor RAM use and it told me that while I only had about 3GB of free RAM, most of the used RAM was filled with disk cache and was virtually considered to be "free" memory. Meaning that Linux was using the RAM to cache hard drive information so that it could be readily accessible, but if a program needed the memory space it would quickly write it over the cache info. Very cool Linux. Here's the link to a more detailed description that I got my information from: LINK.

Also, one more quick note for you newbie Linux geeks like me out there, I ran across a command to clear out the cache in Linux without rebooting. Here it is:

echo 1 > /proc/sys/vm/drop_caches

If my knowledge of scripting isn't horribly failing right now, this is redirecting stdout to drop_caches which must be set to replace the cache with stdin or just to delete it when anything is sent to it. Please pipe up in the comments if you know better than I how that command is working.