0

I have three conflicting sources of information on a process' memory usage. I'm using gnome-terminal as the example process.

ps aux reports a usage of 624480 units for pid 31880 (I say units, because I don't know what it uses as unit), but according to https://superuser.com/a/117921/403466, it's in bytes.

Then I have /proc/31880/status which tells me it's the same amount, but the units are kB:

[...]
VmPeak:   624480 kB
VmSize:   624480 kB
VmLck:         0 kB
[...]

which translates to 624 MiB (completely impossible?); and finally I have gnome-system-monitor which gives me approx. 9.9 MiB.

Which one is correct?

migrated from serverfault.com Mar 10 '18 at 18:25

This question came from our site for system and network administrators.

2

They’re all correct: ps shows kibibytes, as does /proc/.../status. 610 MiB (624,480 kiB) is the process’ virtual size, which is the total amount of address space it has reserved (in its own mappings). 9.9 MiB is its resident size, which is the amount of memory it is actually using.

See Need explanation on Resident Set Size/Virtual Size for more details.

1

Install the smem package if you don't have it already. It is the most accurate. ps -eo pid,command,rss and ps -eo pid,command,size are both a bit inaccurate as they can either not report enough or just too much as they count the memory that's actually allocated.

smem shows the PID, User, Command, Swap, USS, PSS, and RSS. Run it and pay attention to the PSS column. That's the actual amount of physical memory being used and it also accounts for the proper amount of shared memory which is actually used. If you just want PID, Command, and PSS then you can pipe it into awk. For me, that would be columns 1, 3, and 6.

smem | awk '{print $1,$3,$6}'

  • Thanks! Would upvote but somebody took all my rep :/ – Lev Mar 10 '18 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.