I create many graphs that are saved using pylab.savefig and observe that the Python process ends with hundreds of file descriptors for C: \ Python27 \ Lib \ site-packages \ matplotlib \ mpl-data \ fonts \ ttf \ Vera. TTF. In the end, this leads to a process crash due to too many file descriptors (at this moment Vera.ttf has more than 700 descriptors that are viewed through the "Process Explorer").
I see several links to old leaks in matplotlib in archives, but as far as I can tell, they should have been resolved by version 1.0.1.
In my code, I repeatedly call pylab.close ("all"), as well as pylab.close (figure_variable) and figure_variable.clear () in an attempt to get matplotlib to free resources.
For reference, I am using the latest version of the Enthought python distribution for 64-bit Windows. I can duplicate the problem, for example:
for i in range(1000): fig = pylab.figure() pylab.plot(some_data) fig.savefig(filename) fig.clear() pylab.close(fig) if i % 10 == 1: pylab.close("all")
Does anyone know how to get matplotlib to either issue a handle to Vera.ttf or not to reload the same file so many times? From what I observe in Process Explorer, it actually creates several descriptors for each plot.
source share