Per-process memory usage
There are several metrics to measure the amount of memory a process is using. I will begin with the two that are easiest to obtain: the virtual set size (VSS) and the resident memory size (RSS), both of which are available in most implementations of the ps
and top
commands:
- VSS: Called
VSZ
in theps
command andVIRT
intop
, this is the total amount of memory mapped by a process. It is the sum of all the regions shown in/proc/<PID>/map
. This number is of limited interest since only part of the virtual memory is committed to physical memory at any time. - RSS: Called
RSS
inps
andRES
intop
, this is the sum of memory that is mapped to physical pages of memory. This gets closer to the actual memory budget of the process, but there is a problem: if you add the RSS of all the processes, you will get an overestimate of the memory in use because some pages will be shared.
Let’s learn more about the top
and ps
commands.