memory leak in pcolor and pcolormesh

I am using the new transforms version of MPL (the svn trunk), and found a memory leak in pcolor and pcolormesh. Be warned, I just reported a memory leak in the scikits delaunay package that Robert Kern was not able to reproduce, so it might be nice if someone could check this out. I am on Mac OS X, 10.4 using the latest svn versions of numpy and mpl. Here is the code that shows the leak:

from pylab import figure, close, ioff, savefig
from numpy.random import rand

ioff()

for n in range(1000):
     fig = figure()
     ax = fig.add_subplot(111)
     data = rand(1000, 1000)
     ax.pcolormesh(data)
     savefig('foo.png')
     close(fig)
     print n

I get over a gig in real and virtual memory (over 2 gig total) by n=30. I tried both pcolor and pcolormesh, as well as deleting various objects, clearing the axis, etc.

-Rob

···

----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331

Rob Hetland wrote:

I am using the new transforms version of MPL (the svn trunk), and found a memory leak in pcolor and pcolormesh. Be warned, I just reported a memory leak in the scikits delaunay package that Robert Kern was not able to reproduce, so it might be nice if someone could check this out. I am on Mac OS X, 10.4 using the latest svn versions of numpy and mpl. Here is the code that shows the leak:

I have confirmed this on linux.

Eric

···

from pylab import figure, close, ioff, savefig
from numpy.random import rand

ioff()

for n in range(1000):
     fig = figure()
     ax = fig.add_subplot(111)
     data = rand(1000, 1000)
     ax.pcolormesh(data)
     savefig('foo.png')
     close(fig)
     print n

I get over a gig in real and virtual memory (over 2 gig total) by n=30. I tried both pcolor and pcolormesh, as well as deleting various objects, clearing the axis, etc.

-Rob

----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Thanks for finding this.

This should be fixed in r4881. It was a simple reference counting bug.

Please let me know if you still see leaks.

Cheers,
Mike

Eric Firing wrote:

···

Rob Hetland wrote:

I am using the new transforms version of MPL (the svn trunk), and found a memory leak in pcolor and pcolormesh. Be warned, I just reported a memory leak in the scikits delaunay package that Robert Kern was not able to reproduce, so it might be nice if someone could check this out. I am on Mac OS X, 10.4 using the latest svn versions of numpy and mpl. Here is the code that shows the leak:

I have confirmed this on linux.

Eric

from pylab import figure, close, ioff, savefig
from numpy.random import rand

ioff()

for n in range(1000):
     fig = figure()
     ax = fig.add_subplot(111)
     data = rand(1000, 1000)
     ax.pcolormesh(data)
     savefig('foo.png')
     close(fig)
     print n

I get over a gig in real and virtual memory (over 2 gig total) by n=30. I tried both pcolor and pcolormesh, as well as deleting various objects, clearing the axis, etc.

-Rob

----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Michael Droettboom wrote:

Thanks for finding this.

This should be fixed in r4881. It was a simple reference counting bug.

Please let me know if you still see leaks.

That fixed it here. Thank you!

Eric