[PyXMPP] Memory leak via xml nodes?

Chris Becker chris at livefyre.com
Tue Nov 30 23:38:54 CET 2010


I consistently have uncollected xmlNode objects when using the pyxmpp library.  I've used dowser (memory debugging built on cherrypy) and I can't see the objects, but printing out types by topmost ref counts (see script below) always shows uncollected xmlNodes, even after all pyxmpp object instances have been gc'd.   That is, I'm able to identify a JabberClient in memory which is later removed when the client disconnects and references to it are removed.  But each time I create/destroy a JabberClient instance, the number of orphaned xmlNodes increases.

Has anyone else seen this issue?  http://cmeerw.org/blog/639.html this guy complains about it being a pyxmpp-specific memory leak that went away when he switched to a different lib.  But it could just as likely be my mis-use of pyxmpp or the libxml2 objects that I create outside pyxmpp.

Cheers,
Chris

Chris Becker
Lead Engineer - Livefyre.com
chris at livefyre.com
415.730.5611



def get_refcounts():
    d = {}
    sys.modules
    # collect all classes
    for m in sys.modules.values():
        for sym in dir(m):
            o = getattr (m, sym)
            if type(o) is types.ClassType:
                d[str(m)+str(o)] = sys.getrefcount (o)
    # sort by refcount
    pairs = map (lambda x: (x[1],x[0]), d.items())
    pairs.sort()
    pairs.reverse()
    return pairs

def print_top_100():
    pdb.set_trace()
    for n, c in get_refcounts()[:100]:
        print '%10d %s' % (n, c.__name__)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jajcus.net/pipermail/pyxmpp/attachments/20101130/613f08d3/attachment-0001.html>


More information about the PyXMPP mailing list