John Hunter wrote:
On Mon, Jul 14, 2008 at 3:05 PM, Michael Droettboom <[EMAIL PROTECTED]> wrote:
I can confirm this.

Commenting out "del Gcf.figs[num]" in Gcf.destroy (in _pylab_helpers.py)
also seems to resolve the leak.  But I have no idea why, so I won't
commit it just yet.  I don't have much time to look deeper now.  Does
anyone (who probably understands figure management better than me) have
an idea what might cause this?

Can you post the script you are using to test -- I am a little
confused from reading this thread by whether or not twinx is
implicated.  Also, I saw that you committed some changes vis-a-vis the
twinx leak

  r5747 | mdboom | 2008-07-11 13:21:53 -0500 (Fri, 11 Jul 2008) | 2 lines

  Fix memory leak when using shared axes.

so I thought that part was resolved already...

JDH

I use a modified version of the script Laurent Oget posted (see attachment). Here is the output if I don't comment out PL.close(1).

~/python/test$ python looptest.py -dGTK
0 GC 69354 69354 0 13854
100 GC 84354 150 0 15163
200 GC 99354 150 0 16306
300 GC 114354 150 0 17364
400 GC 129354 150 0 18576
~/python/test$ python looptest.py -dTK
0 GC 69521 69521 0 14065
100 GC 84521 150 0 15444
200 GC 99521 150 0 16581
300 GC 114521 150 0 17719
400 GC 129521 150 0 18715
~/python/test$ python looptest.py -dPS
0 GC 59307 59307 0 7705
100 GC 59307 0 0 8037
200 GC 59307 0 0 8038
300 GC 59307 0 0 8038
400 GC 59307 0 0 8038

(so for the window-less backend PS no objects are left)

And now I commented out the line PL.close(1):

~/python/test$ python looptest.py -dGTK
0 GC 69379 69379 0 13855
100 GC 69379 0 0 14253
200 GC 69379 0 0 14253
300 GC 69379 0 0 14253
400 GC 69379 0 0 14252

Manuel
import math
import gc
import pylab as PL
from matplotlib.cbook import report_memory

def looptest():
    oldlen = 0
    for i in xrange(401):
        fig=PL.figure(1)
        ax = fig.gca()
        ax=fig.add_subplot(211)
        ax.set_position((0,0,0.9,0.45))
        ax1=PL.twinx(ax)
        t = PL.arange(1000)
        st = PL.sin(t*0.01)
        ax.plot(t,st)
        fig.clf()
        
        # any of these causes a memleak
        #PL.close(1)
        #PL.close(fig)
        #PL.close()
        
        gc.collect()
        val = report_memory(i)
        if i % 100 == 0:
            print i, "GC",
            print len(gc.get_objects()), len(gc.get_objects())-oldlen,
            print len(gc.garbage),
            print val
        oldlen = len(gc.get_objects())

looptest()
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to