How to tell thread stack usage from Python?
I'd like to log the stack usage of a long-running thread (that is, one that is active during the whole life of the application), how can I do it? Something like "xxxxKB used" would be enough.
(Pytho开发者_如何学Gon 2.6.6, FreeBSD 8.2-RC3)
Since you specified FreeBSD, the resource
module that comes with Python (but only works for Unix-y environments) might be helpful. Specifically, resource.getrusage(resource.RUSAGE_BOTH)
provides will give you the resource usage of that process and all child processes.
It would look like you'd be interested in the following:
ru_maxrss maximum resident set size
ru_ixrss shared memory size
ru_idrss unshared memory size
ru_isrss unshared stack size
精彩评论