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


Attachment: signature.asc
Description: OpenPGP digital signature

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "chandler-dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/chandler-dev

Reply via email to