-1

As far as I know there are several memory concepts: VSS RSS PSS and USS, in which USS(unique set size) is the physical memory exclusively used by a process(correct me if needed).

I think this should be a very useful value to let me know which process uses too many physical memory?

But how could we get this value? By ps or from any /proc file?
(I know a smem tool could help, but is there any built-in method?)

Update 20231015

This answer mentions that /proc/<pid>/smaps_rollup has sum value:

grep "Private" /proc/1748/smaps_rollup 
Private_Clean:     55700 kB
Private_Dirty:     67628 kB
Private_Hugetlb:       0 kB

So we can get the whole value as:

awk '/Private/{ sum += $2 } END { print sum }' /proc/1748/smaps_rollup
2

1 Answer 1

1

The answer to Getting information about a process' memory usage from /proc/pid/smaps includes the instruction to do so. It doesn't hand out the exact command for USS specifically, but it provides all the information and examples required to come up with the command that would work for USS.

  • RSS can be (approximately+) obtained by summing the Rss: entries in smaps (you don't need to add up the shared/private shared/dirty entries).

      awk '/Rss:/{ sum += $2 } END { print sum }' /proc/$$/smaps
    

[...]

  • USS isn't reported in smaps, but indeed, it is the sum of private mappings, so you can obtain it the same way too

So if USS is the sum of private mappings, you do it the same as you sum the RSS, but instead of summing all the line with Rss:, you sum all of the private mappings instead (/Private/ instead of /Rss:/):

awk '/Private/{ sum += $2 } END { print sum }' /proc/$$/smaps

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .