PSS: proportional set size

While looking at /proc/PID/smaps to view memory consumption of the process’s mappings, you might be tempted to look at the RSS (resident set size, the amount of memory resident in RAM), and use that as ultimate, realistic measure of memory usage of a process. The problem with RSS however is that although it accounts for memory of shared libraries (as long as they are in RAM), we don’t have super accurate information on shared pages. For example, you can have 100s of httpd processes, and summing up their RSS would overestimate the total memory usage.

On the other hand, PSS (proportional set size) of the process treats shared memory as a proportion used by the current process. It charges a given process for shared pages divided by the number of sharers. As explained by the LWN article, if a process has 1000 pages all to itself, and 1000 shared with one other process, its PSS will be 1500.

So, when you plot your processes for memory usage, plot both RSS and PSS. Also, when working in a shell you can sum ‘Pss:’ for each mapping of the process:

$ cat /proc/6440/smaps  | grep ^Pss: | awk '{s += $2} END { print s }'

Comments are closed.