Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory_full_info() vs memory_maps() #917

Closed
rohithvsm opened this issue Oct 12, 2016 · 2 comments
Closed

memory_full_info() vs memory_maps() #917

rohithvsm opened this issue Oct 12, 2016 · 2 comments

Comments

@rohithvsm
Copy link

Hi,
Thanks for the great tool. I have an older version of psutil (2.1.0), which means I can't use memory_full_info(). And I can't upgrade to the latest version in my current situation. I was curious about the other function, memory_maps(). In order to get pss of a processs, can I add up the pss field of all the tuples in the list returned by memory_maps()? And will that be equal to memory_full_info().pss? I am sorry, I don't mean to open an issue here. But I am looking for an answer to if this is a reliable method. Thank you for your time.

@giampaolo
Copy link
Owner

Yes, that should do it:

import psutil

p = psutil.Process()
print p.memory_full_info().pss
print sum([x.pss for x in p.memory_maps()])

That should be logically equal.
On my machine that differs by 64K but I suppose it's because memory_maps() build and return an additional dict (which stays in memory).
Full implementation is here:

@wrap_exceptions

....but I'd say you're better off using memory_maps().

@rohithvsm
Copy link
Author

@giampaolo Thanks for your response. I was also trying to derive uss. On similar lines, is the below code snippet also true?

import psutil

proc = psutil.Process()
proc.memory_full_info().uss == sum(pmmap.private_clean for pmmap in proc.memory_maps()) + sum(pmmap.private_dirty for pmmap in proc.memory_maps())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants