Pellegrini Eric wrote:
Hi everybody,
when repeating the following sequence:
pylab.figure()
pylab.close()
the memory used increases like if something remained. Would you have any
idea of what is going on ? How to solve this kind of memory leak ?
I have confirmed this with svn on linux (default backend, GtkAgg) using
the attached script. We are losing about 17k per loop. The usual
memory leak checker still indicates that things are OK. The difference
appears to be the backend. The attached script with Agg instead of
GtkAgg is OK; but with TkAgg it also leaks. It looks like there is
something in the interactive backend setup that is not getting cleaned
up by close().
Thanks for pointing it out.
Eric
#!/usr/bin/env python
import os, sys, time
import matplotlib
#matplotlib.interactive(True)
#matplotlib.use('Cairo')
matplotlib.use('TkAgg')
import pylab
def report_memory(i):
pid = os.getpid()
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
print i, ' ', a2[1],
return int(a2[1].split()[1])
# take a memory snapshot on indStart and compare it with indEnd
indStart, indEnd = 30, 201
for i in range(indEnd):
pylab.figure()
pylab.close()
val = report_memory(i)
if i==indStart: start = val # wait a few cycles for memory usage to stabilize
end = val
print 'Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart))
"""
Average memory consumed per loop: 0.0053k bytes
"""
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users