It seems that the standard way of creating a figure in matplotlib doesn't behave as I'd expect in python: by default calling fig = matplotlib.figure()
in a loop will hold on to all the figures created, and eventually run out of memory.
There are quite a few posts which deal with workarounds, but requiring explicit calls to matplotlib.pyplot.close(fig)
seems a bit hackish. What I'd like is a simple way to make fig
reference counted, so I won't have to worry about memory leaks. Is there some way to do this?