Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do VmRSS and resident set size match?

Tags:

linux

procfs

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
like image 878
lupz Avatar asked May 01 '12 16:05

lupz


People also ask

What is the difference between virtual and resident memory?

Resident memory typically refers to physical RAM installed in the machine. Virtual memory is Hard Disk space reserved for the O/S to act as RAM. The O/S “swaps” data in and out of the virtual memory to place it in RAM, or to take it out of RAM.

What is resident set size Linux?

This is a measure of how much memory a process is consuming in our physical RAM, to load all of its pages after its execution. This includes memory allocated from shared libraries, given they are still present in memory. Also, it includes all heap and stack memory.

Is a process RSS the same or different from its WSS explain?

WSS is the number of pages a process needs in memory to keep "working". RSS is the number of pages of a process that actually reside in main memory. So RSS >= WSS. Meaning that RSS may include some pages that the process doesn't really need right now.

What is RSS in RAM?

In computing, resident set size (RSS) is the portion of memory occupied by a process that is held in main memory (RAM). The rest of the occupied memory exists in the swap space or file system, either because some parts of the occupied memory were paged out, or because some parts of the executable were never loaded.


1 Answers

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.

like image 135
Takashi Oguma Avatar answered Sep 30 '22 17:09

Takashi Oguma