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