How to check memory usage/leak of python script with C extendtion ..

Cary O'Brien cobrien at Radix.Net
Sat Jan 27 08:35:43 EST 2001


In article <94srme$gr9$1 at nnrp1.deja.com>,  <etsang at my-deja.com> wrote:
>Hi,
>
>I am having a python script that interacts with a C executable through
>its pyhon C extension. I would like to monitor the memory usage of the
>whole thing? Do anyone know how to do it? Is there a tool availble for
>memory usage monitoring and memory leakage check for this situation??
>

Hmm.  On unix-like systems you should have "top" which shows memory
usage by process at regular intervals on the screen.  "ps" will do it
also.

Another approach is to use a system call tracer (strace/truss) to see
if your program calls sbrk() after it has initialized itself and
started running normally -- a sign that it is asking for more memory
from the os.

There are also malloc debugger type things of varying cost and complexity
from electric fence to purify (a commercial product).

If you're in the windows world someone else will have to help. Similar
fuctionality is undoubtedly available.

-- cary



More information about the Python-list mailing list