Calculating private and shared memory for processes

Rahul Gore (Nokia) rahul.gore at nokia.com
Fri Feb 10 17:42:53 EST 2023


Hi,

I'm trying to find private and shared memory usage of each process in Linux. One answer on Stack Overflow suggested using 'smem' utility (it reads /proc/<pid>/smap). However, the sum of all PSS values in 'smem' output is not equal to Used value of the 'free' utility (it reads /proc/meminfo).

CLI output:

$ sudo smem -t | tail -n 5
2950301 1002     gfstandalone_1_0 --test hw/        0  1427244  1435899  1453060
2950368 1002     gfstandalone_1_1 --test hw/        0  1432172  1440818  1457588
3012185 rgore    java -classpath /home/rgore        0  2159256  2159348  2163268
-------------------------------------------------------------------------------
  537 23                                     702168 24722224 26865451 62093364
$ free -w
               total        used        free      shared     buffers       cache   available
Mem:        65625036    26415500      511020      351372     1541640    37156876    38119868
Swap:        2097148      726148     1371000


So, I doubt the accuracy of the values in /proc/<pid>/smap. Is there a more reliable alternative?

Regards,
Rahul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20230210/93f78c51/attachment.html>


More information about the Kernelnewbies mailing list