[Chandler-dev] Memory leaks in Chandler

Heikki Toivonen heikki at osafoundation.org
Wed Jun 6 12:21:50 PDT 2007


Here is also a snippet of code that I used to debug memory leaks in
M2Crypto:

import gc

def dump_garbage():
    print '\nGarbage:'
    gc.collect()
    if len(gc.garbage):

        print '\nLeaked objects:'
        for x in gc.garbage:
            s = str(x)
            if len(s) > 77: s = s[:73]+'...'
            print type(x), '\n  ', s

        print 'There were %d leaks.' % len(gc.garbage)
    else:
        print 'Python garbage collector did not detect any leaks.'
        print 'However, it is still possible there are leaks in the C code.'



gc.enable()
gc.set_debug(gc.DEBUG_LEAK & ~gc.DEBUG_SAVEALL)

# test here
a=object()


dump_garbage()


You can put that wrapping around any piece of code (maybe even in
Chandler.py) to see if the Python garbage collector finds any leaks.

-- 
  Heikki Toivonen


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : http://lists.osafoundation.org/pipermail/chandler-dev/attachments/20070606/dfdf0535/signature.pgp


More information about the chandler-dev mailing list