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

It used to be my understanding that top's definition of memory "use" was the number of physical pages mapped to any processes. However, recently I saw something that made me think otherwise. I'd really like someone to explain.

As an example of what I'd expect given my old understanding, below the totaled vmsize from /proc/ is almost three times the "used" in top (89916452KB, 32787948KB). Some pages are mapped to more than one process, some pages are mapped to disk (and so shouldn't be counted at all by top), etc.

$ grep VmSize /proc/*/status | awk '{total += $2} END{print total}'
$ top
top - 09:39:34 up 5 days,  7:37,  9 users,  load average: 4.89, 4.14, 3.92
Tasks: 242 total,   2 running, 239 sleeping,   0 stopped,   1 zombie
Cpu(s): 69.0%us,  0.5%sy,  0.0%ni, 30.3%id,  0.0%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:  32961916k total, 32787948k used,   173968k free,   248132k buffers
Swap: 16777208k total,  1584300k used, 15192908k free,  7659572k cached

However, I recently came across the following. The totaled vmsize is smaller by almost a factor of 4! How could this possibly be the case? Even if one were to argue that the kernel pages that are mapped into each process aren't counted in the VmSize entry in /proc/*/status, one would still have a tough time making the argument that they account for any sizable fraction of the ~46GB in use.

$ grep VmSize /proc/*/status | awk '{total += $2} END{print total}'
$ top
top - 09:43:55 up 291 days, 15:16,  8 users,  load average: 1.02, 1.08, 1.08
Tasks: 291 total,   1 running, 290 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  49324520k total, 46017056k used,  3307464k free,  5448168k buffers
Swap:  8388600k total,      228k used,  8388372k free, 36486236k cached

Please explain.

share|improve this question
up vote 0 down vote accepted

top's "Used" number includes filesystem cache. To get the actual process usage, you'd have to subtract the 36486236k cached from the 46017056k used. Not sure if buffers are counted in the per process status file, but you might have to subtract them as well.

The free command shows this with a line for "-/+ buffers/cache:" showing what's actually "used" and "free" when you exclude those.

share|improve this answer

Your Answer


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.