Managed Hosting by 1-800-HOSTING

Linux: Low memory – feature or a bug?

June 9th, 2009 by Jonathan Kelley

Linux actually handles RAM differently than Windows, and this can cause confusion to an administrator in charge of a system. Customers sometimes contact us with worries of low ram, memory leaks and other problems wondering why their system is constantly low on RAM. Case in point: A dedicated customer once ordered two RAM upgrades before opening up to us about his concern with memory leaks. We were finally able to share with him that he had plenty!

Imagine, Apache has been having some strange issues with faults and sigterms mentioned in log files. Today your boss is upset because it happened during a live product demo and the site went down while some major investors were checking it out. You’ve been tasked not-so-lightly with finding out why. You try some things, then check the memory usage.

[root@why-so-plagued-for-ram.local ~]# free -m
total       used       free
Mem:          3289       3126        162
-/+ buffers/cache:        567       2721
Swap:         1027          0       1027

You may think you’ve pinned the problem! Merely 162 megabytes of RAM available can certainly cause problems. Come mid-day, that will be exhausted! However, a closer inspection shows you have 2721 megabytes free memory. See the -/+ buffers/cache part? That’s cached memory, that is actually available usable system memory. You’ve got plenty!

What is -/+ buffers/cache?

Linux uses buffers/cache for disk caching (possibly other functions as well) to help your overall system performance. This makes I/O operations and other functions the kernel uses go quicker. The kernel figures if there’s RAM to use, why not use it? (Why not?)

If a program were to start that needs the memory, the buffer is dynamically re-sized to exclude the memory needed by the application. It’s harmless, interferes with programs in no way, and helps your system do other operations faster via the speed of your memory. What’s not to love?

As for those Apache issues, hopefully you’ll figure them out before your boss has another incident! At least you’ve solved the issue with the memory. It’s not a bug, leak, or coding issue: it’s a feature.

I’d like to credit Vidar at Linux Ate My Ram! for addressing this issue for the internet community at large, and for being the inspiration of this posting. [He has also written source code to prove this theory should anyone want to experiment.]

 

Related Posts

Tags: , , , ,

One Response to “Linux: Low memory – feature or a bug?”

  1. Bobby says:

    Love your posts; can’t wait to see more!

Leave a Reply

You must be logged in to post a comment.