Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

UPDATE:

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 has been asked before and already has an answer. If those answers do not fully address your question, please ask a new 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

1 Answer 1

              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?

http://stackoverflow.com/questions/6345020/linux-memory-buffer-vs-cache

share|improve this answer

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