How do VmRSS and resident set size match?

lupz picture lupz · May 1, 2012 · Viewed 37.7k times · Source

I parse data from /proc/[pid]/statm to get a clue about memory usage of a certain process. man proc states that resident set size(measured in 'pages') is the same as VmRSS (KB??) in /proc/[pid]/status. Since they have different values, I would like to understand the connection between these Values. Is there something like a factor I can read somewhere in /proc (I thought of VmPTE but its sth. else...)? Which one of both should I parse to get the size of the used Memory for a certain process?

#ex 1782 = firefox

~$ cat /proc/1782/statm
  224621 46703 9317 11 0 98637 0
#          \--- resident set size

~$ cat /proc/1782/status | grep Vm
  VmPeak:     935584 kB
  VmSize:     898484 kB
  VmLck:           0 kB
  VmHWM:      257608 kB
  VmRSS:      186812 kB
  VmData:     394328 kB
  VmStk:         220 kB
  VmExe:          44 kB
  VmLib:       61544 kB
  VmPTE:        1224 kB
  VmSwap:          0 kB

Answer

Takashi Oguma picture Takashi Oguma · Jun 19, 2013

The RSS value of /proc/<pid>/stat is number of pages, whereas the VmRSS value of /proc/<pid>/status is in kB.

In your case, 46703 * 4kB (page size) = 186812 kB.