memory leak in canvas.draw() in TkAgg

You may have already seen this in the general mailing list, but I've
found what I think is a serious memory leak in matplotlib 1.0.0: it
leaks memory every time canvas.draw() is called, at least when using
TkAgg on unix and Mac.

Admittedly many graphs do not need canvas.draw() to be called repeatedly
(which I suspect is how it has survived this long). This came up in the
context of a strip chart widget, where I am changing the x/time axis
limits regularly and calling canvas.draw() so that the change is visible.

I submitted ticket 3124990 with a very simple demo script:
<https://sourceforge.net/tracker/?func=detail&atid=560720&aid=3124990&gro
up_id=80706>
(you can disable the setting the x limits if you want to see the leak in
its purest form, but then nothing changes visually on the graph).

I just wanted to be sure folks know about it in hopes somebody might
have an idea how to fix it. I have not tried any other back ends.

-- Russell

I think I'm on to something -- it seems that text layout information has a cyclical reference that prevents the Text object from being freed.

Can you apply the attached patch and let me know if it solves your issue?

Mike

text_memleak.diff (1.16 KB)

ยทยทยท

On 12/10/2010 02:19 PM, Russell E. Owen wrote:

You may have already seen this in the general mailing list, but I've
found what I think is a serious memory leak in matplotlib 1.0.0: it
leaks memory every time canvas.draw() is called, at least when using
TkAgg on unix and Mac.

Admittedly many graphs do not need canvas.draw() to be called repeatedly
(which I suspect is how it has survived this long). This came up in the
context of a strip chart widget, where I am changing the x/time axis
limits regularly and calling canvas.draw() so that the change is visible.

I submitted ticket 3124990 with a very simple demo script:
<https://sourceforge.net/tracker/?func=detail&atid=560720&aid=3124990&gro
up_id=80706>
(you can disable the setting the x limits if you want to see the leak in
its purest form, but then nothing changes visually on the graph).

I just wanted to be sure folks know about it in hopes somebody might
have an idea how to fix it. I have not tried any other back ends.

-- Russell

------------------------------------------------------------------------------
Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL,
new data types, scalar functions, improved concurrency, built-in packages,
OCI, SQL*Plus, data movement tools, best practices and more.
http://p.sf.net/sfu/oracle-sfdev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options
   
--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA