Has anyone seen matplotlib skipping file descriptors (Vera.ttf) on Windows 7 with version 1.0.1?

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.

+4
source share
1 answer

There are several pending pull requests to solve this problem, one of which will turn into Matplotlib v1.1.1 (next stable release): see # 795 and # 798 for two alternatives and participate in # 791 , which is the topic for testing release candidates v1.1.1.

A fix similar to the sentence in # 795 was applied to the git branch 7 months ago, so if you are on that you should no longer see this. The only caveat is that it uses a with statement, so it won’t work on Python <2.6

+2
source

All Articles