xmpppy/xmpppy

Help requested - Another Memory leak

CyrilPeponnet opened this issue · 2 comments

I spotted another potential memory leak here:

dispatcher.py:

    def SendAndCallForResponse(self, stanza, func, args={}):
        """ Put stanza on the wire and call back when recipient replies.
            Additional callback arguments can be specified in args. """
        self._expected[self.send(stanza)]=(func,args)

Actually and contrary to SendAndWaitForResponse, the self._expected dict remains wired to all stanza/cb receveid as you ca see here:

graph dot

We clearly see that self._expected contains all ID and what ever they are linked too.

I try to figure out how to fix this, I'm asking for help about that.

Thanks

I can remember fighting memory leaks myself.

I'm not very sure if that was xmpppy, but it's very likely. The solution
was to break these dependency loops in del to ease work of GC.

Also, I believe, another solution happened to be to migrate to newer
cpython interpreter, which handled dependency loops. That was early 2007,
so most likely that was CPython 2.6.
Am 14.09.2014 02:00 schrieb "Cyril Peponnet" notifications@github.com:

I spotted another potential memory leak here:

dispatcher.py:

def SendAndCallForResponse(self, stanza, func, args={}):
    """ Put stanza on the wire and call back when recipient replies.            Additional callback arguments can be specified in args. """
    self._expected[self.send(stanza)]=(func,args)

Actually and contrary to SendAndWaitForResponse, the self._expected dict
remains wired to all stanza/cb receveid as you ca see here:

[image: graph dot]
https://cloud.githubusercontent.com/assets/2277387/4262430/f3d42db0-3ba1-11e4-9325-5c6233f0b67e.png

We clearly see that self._expected contains all ID and what ever they are
linked too.

I try to figure out how to fix this, I'm asking for help about that.

Thanks


Reply to this email directly or view it on GitHub
#18.

Actually cleaning the _expected dict seems to do the trick.

            if type(session._expected[ID])==type(()):
                cb,args=session._expected[ID]
                del session._expected[ID]

Not sure why only the cb case the _expected dict was not cleared but it seems to fix the memory ballooning issue.