Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

My understanding of the output of free is that buffer/cache values are a true reflection of available memory.

I have assigned 512M to PHP APC opcode cache and although it is utilising all of this the output of free remains the same.

I know that the issue lies in my understanding (or lack thereof) of memory management. Can someone please give me some insight into this?


My understanding of memory comes from the studying of assembly that I've done. What (at least I think) I don't know about is how the Linux kernel manages the memory.

Since posting the question I've read more and my understanding is that, at the simplest level, they are as their names suggest - cache is the kernel mirroring files to RAM for faster access and that buffers are transient bits of information being used by individual processes.

APC running (512M fully utilised):

              total       used       free     shared    buffers     cached
Mem:           1498       1452         46          0         36        796
-/+ buffers/cache:         619        879

Immediately after restarting PHP FPM with APC disabled:

              total       used       free     shared    buffers     cached
Mem:           1498        776        721          0         36        285
-/+ buffers/cache:         454       1043

Ignoring swap space as it remained unchanged:

Line one makes sense to me, memory is freed from both APC (512M) and the PHP workers (721-46-512 = 163M). Memory assigned for cache no longer has APC to deal with and reduces by 796-285 = ~512M (or is this just a coincidence?).

It's the second line that is confusing me. Are these numbers just how much the kernel has reserved for buffers and the rest is allocated to caching even if not actually used currently? This would make sense because it drops by the same amount I calculated as being used by PHP, reflecting the PHP workers.

If I am correct then another question arises. What is reflected by "buffers" on line one?

share|improve this question

marked as duplicate by mgorven, growse, sysadmin1138 Feb 18 '13 at 22:11

This question was marked as an exact duplicate of an existing question.

It's not really clear from your question what your understanding of the memory stats is, nor why your experience doesn't match your expectations - perhaps if you provided the output of free on a cold system and once APC is populated we would understand beter. – symcbean Sep 10 '12 at 12:55
              total       used       free     shared    buffers     cached
Mem:           1498        776        721          0         36        285
-/+ buffers/cache:         454       1043

The second line, 454 = used(776) - (buffers(36)+cached(285))

1043 = free(721) + (buffres(36)+cached(285))

The values will be approximated.

What is buffer?

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.