The more I read, the more confused I get.. I want to generate a list of processes and their memory consumption (physical + virtual).
So far, this is what I have done:
- I take the VSZ of each process, and multiplying it with 1024 (into bytes)
- I take the RSS, and does the same
- Then I subtract the VSZ with the RSS, since VSZ contains RSS already
Instead of showing all the threads, I sum up the processes with the same user+comm.
This gives me a list similar to this:
MEM VMEM PMEM User Command 16.27 GB 15.47 GB 811.73 MB apache httpd 2.37 GB 2.19 GB 186.12 MB mysql mysqld 372.99 MB 320.18 MB 52.81 MB memcached memcached 985.78 MB 954.60 MB 31.18 MB root httpd
The MEM column is basically VMEM (VSZ - RSS) + PMEM (the RSS).
But I was a bit baffled by this.. Apache spawns ~ 10 threads, and this list says it is consuming 16 GB of memory. The hard drive is only ~14 GB, and we have 8 GB of RAM.
So then I thought: "Even though the VSZ is different for each thread, perhaps it is sort off a value that is absolute for every thread". So if I took the VSZ column and subtracted each thread's RSS, I got this:
MEM VMEM PMEM User Command 1.38 GB 680.54 MB 737.68 MB apache httpd 2.55 GB 2.37 GB 186.09 MB mysql mysqld 425.80 MB 372.99 MB 52.81 MB memcached memcached 1016.96 MB 985.78 MB 31.18 MB root httpd
And I though: "Well, this must be true!".
Question is, am I right? I just cannot believe that apache is consuming 16 GB of memory.
Am I doing something horrible wrong here?
Updated: I am getting the same values when using
top. It's also a CentOS machine.