Memory leak with pcolor

Thanks for your advice with installing matplotlib on cygwin. I downloaded and installed the windows binaries and it worked.

Anyway, the reason that I didn’t want to use binaries in the first place was because I wanted to modify the matplotilb source code. But it seems like even with the binaries, if I change the source code then it will still affect the operation of the program when I run it, which is what I want.

In particular, I am looking to speed up the pcolor() function because it runs exceedingly slow with large mesh sizes. I believe the reason it is running slow is because of a memory leak. When I do the following:

from pylab import *
z=sin(x2 + y2)

and then do


repeatedly, the memory usage increases by about 15 MB each time, and it runs progressively slower.each time. By using the profiler I can see that almost all the time is spent in the pcolor function itself, rather than any functions it calls. When I take out the line “self.add_collection(collection)”, there is no memory leak and it runs much faster (of course, since I’m not actually adding the collection on, when I do that i can no longer actually see the plot). It seems to me like what is happening is that it is repeatedly appending the same PolyCollection to the collections list, using up more and more memory. What I want to know is what the “collections” are and how they are used so I can figure out a way of getting rid of extraneous collections.

-Alexander Mont