How can I get Memory/CPU stats for the python VM?
Martin von Loewis
loewis at informatik.hu-berlin.de
Fri Feb 2 23:25:15 CET 2001
Terrel Shumway <tshumway at transafari.com> writes:
> I am running Python 2.0 on a Linux box that has an protected /proc/.
> How can I find out how big the python process is and how much CPU time
> it is taking?
time python foo.py
gives you the execution time.
> The profile module is not enough:
> 1) I need to get info from a deployed process (non-debug)
> 2) It doesn't give memory stats
> Rebuilding the python interpreter or an extension module *is*
With the gc module, you can get the number of living objects. With the
resource module, you can get shared and unshared memory sizes etc, if
your operating system supports that. Unfortunately, Linux reports
zeroes in many of these fields. Reading /proc/self/maps or
/proc/self/stat* will provide the proper detail on Linux - you only
need to find the kernel documentation to interpret these numbers :-)
Hint: /usr/src/linux/fs/proc/array.c has the code that generates these
More information about the Python-list