Hello Michael, I have not tried using plt.figure() and plt.close(fig) but you are right; I should investigate it as well for completeness. I had, actually, purposefully avoided doing this because I read that the pyplot API is stateful. It keeps references to figures in the same way that MatLab does and these figures need to be explicitly closed (via plt.close). By calling Figure(...) directly I am trying to use matplotlib's object-oriented API and avoid pyplot's statefullness.
Something interesting and perhaps enlightening is to switch backends from Agg to something else (say Cairo). In the demonstration script that I posted you would do so like this: #from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.backends.backend_cairo import FigureCanvasCairo as FigureCanvas When using the Cairo backend the memory leak disappears. In my mind, this indicates a memory leak when using the Agg backend that DOES NOT appear when using the Cairo backend. Thanks for the advice; I will give pyplot a try and see if I get different behaviour. Sincerely, Keegan Callin On 04/19/2010 11:28 AM, K.-Michael Aye wrote: > Could you try to use figure() instead of Figure()? That often creates a > mess on my side. > Or should one use Figure() in the 'Artist's style? I am still importing > pyplot as plt, and in that case, I have to use figure(), otherwise > things don't work. > > I also had the feeling of a leak and am currently doing this without > much 'leaking': :) > > fig = plt.figure() > ax = fig.add_subplot(111) > im = ax.imshow(nData) > cb = plt.colorbar(im) > ax.set_title(bname + ', ' + mode) > fig.savefig(filename + '.equal.png') > plt.close(fig) > > I think, the plt.close(fig) was quite important in my case. > Give it a try! > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users