Hey Ryan,

On Fri, Oct 1, 2010 at 6:27 AM, Ryan May <rma...@gmail.com> wrote:
> On Fri, Oct 1, 2010 at 1:05 AM, Fernando Perez <fperez....@gmail.com> wrote:
>> This manifested itself in some more complex MPL code that had multiple
>> events not working when run inside ipython, but working OK outside of
>> ipython.  Fortunately, the small self-contained example demonstrates
>> the problem even with ipython not being in the picture at all (the
>> runs above were from the command line), so I think there is an issue
>> in MPL proper.
>>
>> Sorry that I can't dig deeper into the code right now to look for a fix...
>
> Somewhere in the 1.0 development cycle, Michael modified the callback
> code to take weak references to methods.  The purpose was to eliminate
> some "leaks" that were occurring because callback connections to
> objects were keeping them around and the proper disconnects were not
> made (much simpler fix than tracking down every mpl_connect and trying
> to see where do disconnect). What you're seeing in your script is that
> since you're not assigning the Handler object to anything, it's being
> garbage collected. It works for me if I change the second to last line
> to:
>
>    h = Handler(f)

Many thanks for the info, that helps a lot.

I was wondering though, would we still have a leak if strong
references are held in the canvas attribute?  The canvas will be
deleted when the figure goes away, so that should properly allow the
callback references to be deleted, without deleting them early
otherwise, no?

In any case, if my logic is flawed (quite likely, since I imagine M.
D. had a good look at this), it might be worth adding a

.. warning::

section about this pattern to the event docs:

http://matplotlib.sourceforge.net/users/event_handling.html

because the problem is subtle and hard to diagnose (I just noticed it
had also been reported recently
http://sourceforge.net/mailarchive/forum.php?thread_name=4C9B7793.5020908%40gmail.com&forum_name=matplotlib-devel).

In any case, thanks again for the help!

Cheers,

f

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to