|
From: A B <pyt...@gm...> - 2009-02-11 04:12:17
|
On Mon, Feb 9, 2009 at 9:59 PM, Jouni K. Seppänen <jk...@ik...> wrote: > Ryan May <rm...@gm...> writes: > > > On Mon, Feb 9, 2009 at 2:37 PM, A B <pyt...@gm...> wrote: > > > > If you're using the full OO interface and creating a figure by making an > > instance of Figure(), then you shouldn't need to close the figure by > hand. > > It should be deleted whenever you delete or replace your instance of > > Figure. (If I understand correctly.) > > Yes, in the OO interface there is no close() because matplotlib does not > retain any references to the figure object. Garbage collection will take > care of reclaiming memory once the user code has no more references to > the object either. > > That said, there have been cases of memory leaks caused by circular > references among objects that have __del__ methods. I think all known > leaks have been fixed, but if I were deploying a long-lived application > that creates lots of figures, I would definitely want to watch its > memory usage in my exact use case. > > -- > Jouni K. Seppänen > http://www.iki.fi/jks > Thank you. The reason I asked the question was that with the OO interface, I still observed growth in memory consumption (more than I saw after I added pyplot.close() calls). However, at some point (90M which I still think is a lot) the growth tapered off and eventually seemed to have stopped. Essentially, what I do is create a figure, then call plot() on it in a loop to generate multiple curves, then print_png() on the canvas object. |