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?