Measuring peak memory using resource.getrusage

I am trying to measure the peak memory usage in a long running Python process using resource.getrusage(resource.RUSAGE_SELF).ru_maxrss

(see this ).

Does it resource.getrusage(resource.RUSAGE_SELF).ru_maxrss

report the peak memory usage for the lifetime of a process when called once before exiting the process, or do I need to periodically call it on a background thread as the process runs and take on the largest of all return values? The documentation is somewhat unclear on this issue.

+3


source to share





All Articles