Jeff Whitaker wrote:
Jesper Larsen wrote:
Hi matplotlib users,

I'm using matplotlib for a long running process. Unfortunately the memory usage continue to grow as the process runs. I have appended a simple example which illustrates this at the end of this mail. Unfortunately I haven't figured out how to use the information obtainable from gc for anything useful in this regards.
[...]
Jesper: Looks to me like the memory leak is not in Basemap, but somehow the fig.clear() is not working properly. Replacing the fig.clear() with pylab.gca() gets rid of the memory leak. I will investigate further ...


-Jeff


Jeff, this might be related to the leak illustrated in the attached script, based on an earlier report. (I don't recall who reported it.)

Eric

#!/usr/bin/env python
'''
This illustrates a leak that occurs with any interactive backend.
'''
import os, sys, time
import matplotlib
matplotlib.use('GtkAgg') # or TkAgg or WxAgg
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(1)
    pylab.close(1)
    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))

-------------------------------------------------------------------------
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

Reply via email to