As a Linux user/administrator, It’s important to monitor the memory usage of the system and make sure the Apps are running with enough resources. To view to memory usage of your Linux box is simple, just use the command:
$ free -m
But do you understand all these numbers? Sounds obvious, I have total of 496MB memory, used 271MB and 225MB is free. Sometimes I see even smaller value of “free” memory, makes me wonder what actually eat up my memory. But wait….What is “buffers”, “cached” and “-/+ buffers/cache”? You’ll notice when the buffers and cached went up, the “free” will decrease. To understand what’s going on here, you need to know how Linux works.
Leaving your memory idle is not a good idea
Firstly, it’s important to know that memory or RAM is about 500x faster than a Hard drives and the access time is measured in nano-second. You definitely want your data/program ready in the memory when you need it! So that you don’t have to wait for the hard drive. What Linux do is that it will keep portion of the files you have used before (or will use soon) in the memory, to improve the performance of the OS, this is called caching. However, those memory can still be used when necessary.
Caches are also “Free” memory
From the example above, essentially I have 372MB of memory available for applications. As the memory usage of apps increase, the OS will free up the memory for the apps. Generally you don’t want to see a lot of free memory, because that means you’re wasting the resources. You want them to be used by the OS to improve overall performance, however when you notice there’s constantly very little free and cache memory, you may consider adding more memory to the system.
- free -m
- ps_mem.py (A tool to view how much memory the apps actually used)