0

Possible Duplicate:
Meaning of the buffers/cache line in the output of free
Why is Linux reporting “free” memory strangely?

I have a 12GB RAM VPS where I host a a couple of static websites , 2 small Magento powered stores and a couple of WordPress installations - overall nothing exciting and generally low traffic.

I've noticed though that my memory consumption is quite high - kindly have a look at the results of free m below:

             total       used       free     shared    buffers     cached
Mem:      12306384   12137728     168656          0     753360    8629744
-/+ buffers/cache:    2754624    9551760
Swap:      1048564        104    1048460

Also see a screenshot out of Mumin http://s13.postimage.org/q2xewgnef/Screenshot_4.jpg

Now I reckon that 9,5 GB seem to be buffer / cache related - however I find this quite high. Is this something I have to worry about or will they eventually free themselves ? (I've read it somewhere but I am certainly not an expert)

Another note on the side is that Memcached has been installed once and applied to one of my Magento installation - could it be related to it?

Some expert advise would be truly appreciated.

  • As in the duplicate pointed out above, the link to http://www.linuxatemyram.com/ might be helpful. – dunxd Jan 04 '13 at 11:13

1 Answers1

2

You walk into a factory and all the employees are working. "Why aren't employees sitting on a couch doing nothing?", you wonder. Well, duh, that's kind of dumb. The employees should be working, not sitting around waiting for work.

If you're thinking "I want the RAM to be free now so I can use it later", well that's dumb too. You don't need the RAM to be free now to use it later. You can use it now and use it later and get the best of both worlds.

It's not like if you use only 8GB today you can use 20GB tomorrow. Not using memory right now provides no advantage whatsoever, just opportunity lost forever. There is no cost associated with using memory that the system has and so no reason not to use as much of it as you possibly can.

Say the system did make more memory free. One of two things would happen:

  1. That memory wouldn't be used later. In which case, the effort of making it free would be completely wasted.

  2. That memory would be used later. In which case, the effort of making it free would be wasted, since it would just have to make it used again.

Modern operating systems only make memory free when they have absolutely no choice. It takes effort to do so, and that effort just has to be undone when the memory is used again. Instead, the memory is directly transitioned from one use to another without ever being free. Free memory is only needed for special use cases where memory cannot be transitioned from one use to another, such as in an interrupt context. Only a very small amount of free memory is needed for that purpose, typically 64MB or less.

David Schwartz
  • 31,215
  • 2
  • 53
  • 82
  • http://linuxatemyram.com is more entertaining. :) – Michael Hampton Jan 04 '13 at 05:23
  • @MichaelHampton: I find that site encourages the mistaken belief that "free memory is good" rather than pointing out how wrongheaded it is. Free memory is bad -- it represents waste and cost. You should want as little of it as possible. – David Schwartz Jan 04 '13 at 05:23
  • Strange, your reading of that site is quite different than mine. – Michael Hampton Jan 04 '13 at 05:24
  • For example, it says, `But what do you call memory that is both used for something and available for applications? You would call that "free", but Linux calls it "used".` Why would I call that free? It is in fact used. Rather than correcting this as a misunderstanding, it's suggesting that understanding is *correct*. For example, later under "How do I see how much free RAM I really have", it suggests that the idea that 99% of the RAM is free is correct when it's not. – David Schwartz Jan 04 '13 at 05:27
  • You would call that "free" if you were a new user who didn't understand that Linux is actually doing something with that "free" memory. You wouldn't call it "free" if you actually knew what was going on, which is the whole point of the site. – Michael Hampton Jan 04 '13 at 05:28
  • No, it means that you should call that free, not that doing so is a mistake. Look further down, where it says: "If you don't know how to read the numbers, you'll think the ram is 99% full when it's really just 42%." 42% full would be horrible waste, and that's *not* what's happening. Then it says gobbledygook things like "how much ram is free to use for your applications" which doesn't make any sense. That's why I don't recommend that site. – David Schwartz Jan 04 '13 at 05:29