Thanks Michael ,

I had somehow put myself under the impression i was using he OO
version of the api but it is much more clear now. Memory issues now
look better.

Thanks.

2009/2/10 Michael Droettboom <md...@stsci.edu>:
> This is an instance of the OP's problem again.  Your example is using the
> pyplot (i.e. Matlab-like) interface, in which case, you must explicitly
> close each figure when you're done with it, like follows:
>
>  plt.close(fig)
>
> "del fig" only deletes your local reference to the figure.  There is still a
> reference being held by the figure manager in case you wanted to go back to
> an earlier figure (accessed by number) and edit it.  This is essentially the
> price paid for Matlab-work-a-likeness.
>
> I've tested your script on 0.98.3 (though on a RHEL4 system) and I don't see
> any memory leaks after adding the call to "plt.close(fig)".
>
> If you instantiate the figure and canvas directly (as in the agg_oo.py
> example), you won't have this issue.
>
> Mike
>
> Gerry Steele wrote:
>>>>
>>>> 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.)
>>>>
>>
>>
>>>
>>> ... Garbage collection will take
>>> care of reclaiming memory once the user code has no more references to
>>> the object either.
>>>
>>
>>
>> I guess that is how it should work in theory. However at least for the
>> version of mpl shipped with ubuntu 8.10 (Version: 0.98.3-4ubuntu1)
>> there is surely quite a serious and easily demonstrated memory leak
>> using the artist api. Even if you manually del the figure objects
>> which are created inside a loop a significant growth of memory can be
>> observed. In fact I think there may be two separate leaks.
>>
>> In the attatched standalone code example after 1000 iterations
>> creating 1000 png graphs there is around 2GB of RAM consumed. If you
>> takeout the call to savefig around 600MB is consumed.
>>
>> In my view the code in the loop should execute in constant space
>> without growth at all. Note that when the function returns the memory
>> seems to be deallocated so if you check the ram use during the sleep
>> you should see this.
>>
>> Any ideas on this?
>>
>>
>>
>>  ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>> Create and Deploy Rich Internet Apps outside the browser with
>> Adobe(R)AIR(TM)
>> software. With Adobe AIR, Ajax developers can use existing skills and code
>> to
>> build responsive, highly engaging applications that combine the power of
>> local
>> resources and data with the reach of the web. Download the Adobe AIR SDK
>> and
>> Ajax docs to start building applications
>> today-http://p.sf.net/sfu/adobe-com
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
> --
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>
>



-- 
Gerry Steele
http://belfast.no-ip.info/

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to