2

In the output of top, I heard that RES of a process is the part of RAM occupied by the process, and includes the process' code, data, and shared libraries which are in RAM.

I wonder if RES of a process includes or excludes the cache and buffer of the process?

Similar question for USED of a process, i.e. does USED of a process include or exclude the cache and buffer of the process?

I have this question because in the output of free, there are items for cache and buffer, which are both counted and excluded from used, although not for a single process but for all the processes.

Thanks.

2 Answers 2

3

The filecache and all buffers are not in any way associated to a process. If 2 processes access a file, which causes it to be in the cache, the kernel does not remember who accessed the file.

Take a look at /proc/meminfo and its explanation.

To see what a process occupied memory consists of, you can see the files maps and smaps in /proc/PID directories for each process. There you will find which libraries are part of it and also mmapped files, but those do not occupy any memory, they are just mapped into a process' memory space.

0

Yes. The process RES includes the cached at least in my case when the cached is used for mmapped files:

top - 05:07:51 up 7 days,  6:37,  1 user,  load average: 0.37, 0.28, 0.22
Tasks: 219 total,   1 running, 125 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:  64463540k total, 63729264k used,   734276k free,    97804k buffers
Swap:        0k total,        0k used,        0k free, 14275740k cached
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 4772 druid     20   0 96.8g  57g  11g S  0.0 93.9 254:51.01 java

You can see that 57g+14275740k cached will be exceeding the 64463540k total if they are mutually exclusive.

You can verify that by looking at /proc/PID/status, RssFile should be the total mmapped file size.

Unfortunately, the only answer under the only question I can find on this topic on the internet can't explain what I am seeing on my system, took me quite some time to figure that out, hopefully I can help more people here.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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