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

I wanted to profile the memory usage of a script. Here's the output before it was running:

procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
0  0  15624 186660  39460 439052    0    0     0     2    1    1  0  0 100  0

Here's the output while the script is running, at the point where free memory was at its lowest value:

procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
0  0  15624  11464  40312 473524    0    0     0     2    1    1  0  0 100  0

So free memory dropped by about 175 MB, and I expected that buff would increase by that amount. But it seems the other columns changed by relatively negligible amounts - how is this possible? Am I interpreting this wrong, or is some memory just not being accounted for in this output?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Some of the additional memory that is no longer free is being used as cache. We can't tell from just this information what the rest of the memory is being used for, but most likely it's kernel-level caches of things like filesystem metadata. So memory that was previously holding something that couldn't possibly be useful is now holding information that might be useful. So this shows things getting better.

share|improve this answer
    
So the sum of swpd + free + buff + cache does not need to be constant on any particular machine? –  jimbotron Oct 27 '13 at 14:58
    
@jimbotron No, because the amount of memory the kernel is using can change. –  David Schwartz Oct 27 '13 at 15:23
    
See slabtop and /proc/slabinfo –  Joshua Miller Oct 27 '13 at 23:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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