1

Get the Proportional Set Size (PSS) memory use of a Linux process

sudo cat /proc/1/smaps | grep '^Pss:' | tr -s ' ' | cut -d' ' -f2 | paste -sd+

June 16, 2023harisokanovic

Explanation

  • sudo cat /proc/1/smaps: print the content of smaps of process 1. Running it with sudo, because regular users don't have access to such level of process memory accounting details.
  • | grep '^Pss:': filter the output, keeping only lines that start with "Pss:"
  • | tr -s ' ': squeeze the output, by replacing repeated spaces with a single space
  • | cut -d' ' -f2: extract the second field from the output, using space as the delimiter
  • | paste -sd+: paste all the lines together, delimited by "+"

Replace 1 with the PID of a command for which you want to see the Proportional Set Size value.

See more information about Linux memory accounting at: https://www.kernel.org/doc/html/latest/filesystems/proc.html

Limitations

Only works in Linux.