On 2010-04-16 19:18:56 +0200, Keegan Callin said:
> Hello,
>
> I have written a small script that, I think, demonstrates a memory leak
> in savefig. A search of the mailing list shows a thread started by Ralf
> Gommers <[email protected]> about
> 2009-07-01 that seems to
> cover a very similar issue. I have appended the demonstration script at
> the end of this e-mail text.
>
> [kee...@grizzly ~]$ python2.6
> Python 2.6.4 (r264:75706, Jan 20 2010, 12:34:05)
> [GCC 4.4.2 20091222 (Red Hat 4.4.2-20)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import matplotlib
> >>> matplotlib.__version__
> '0.99.1.1'
> '''
> # Import standard python modules
> import sys
> import os
> from ConfigParser import SafeConfigParser as ConfigParser
> from cStringIO import StringIO
>
> # import numpy
> import numpy
> from numpy import zeros
>
> # Import matplotlib
> from matplotlib.figure import Figure
> from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
>
>
> def build_figure(a):
> '''Returns a new figure containing array a.'''
>
> # Create figure and setup graph
> fig = Figure()
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!
Best regards,
Michael
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users