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

Will Ware wware at world.std.com
Sat Jan 27 09:49:55 EST 2001


etsang at my-deja.com wrote:
> 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??

I did something like this once. It turns out that part of this facility
is already built into the Python source code. If you don't mind recompiling
Python, you can try what I did:
http://www.deja.com/getdoc.xp?AN=672487959&fmt=text
What I was doing was to print the sum of all the reference counts for all
the objects. Memory problems are often associated with mismanagement of
reference counts. So if you go into a for-loop and the total number of
refcounts rises each time thru the loop, it's a likely indication that
you might need another DECREF somewhere.

-- 
import string,time,os;print string.join((lambda x:x[:10]+x[8:])(map(
lambda x:string.center("*"*(lambda x:((x<24) ### Seasons Greetings, Will Ware
*(x-3))+3)(x),24),range(1,28, 2))),"\n") ################ wware at world.std.com



More information about the Python-list mailing list