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.
>
> Kind regards,
> Jesper
>
>
> My system is:
>
>   
>> uname -a
>>     
> Linux sea 2.6.15-28-686 #1 SMP PREEMPT Thu Feb 1 16:14:07 UTC 2007 i686 
> GNU/Linux
>
>   
>> python
>>     
> Python 2.4.4 (#1, Nov 16 2006, 13:39:46)
> [GCC 3.3.3 (Debian)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>   
>>>> import matplotlib
>>>> print matplotlib.__version__
>>>>         
> 0.87.6
>   
>>>> from matplotlib.toolkits import basemap
>>>> print basemap.__version__
>>>>         
> 0.9.4
>
> Test code:
>
> import os, gc
> import PyNGL.Nio as Nio
> from matplotlib.toolkits import basemap
> from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
> import pylab
>
> def report_memory(i):
>   pid = os.getpid()
>   a2 = os.popen('ps -p %d -o rss,vsz,%%mem' % pid).readlines()
>   print i, ' ', a2[1],
>   return int(a2[1].split()[1])
>
> def plot():
>   #gc.set_debug(gc.DEBUG_LEAK)
>   lon = pylab.linspace(-4.08300018311, 30.25, 207)
>   lat = pylab.linspace(48.5499992371, 65.8499984741, 174)
>   xo, yo = pylab.meshgrid(lon, lat)
>   bmap = basemap.Basemap(-4, 48, 30, 66)
>   xlon, ylat = bmap(xo,yo)
>
>   fig = pylab.Figure()
>   canvas = FigureCanvas(fig)
>
>   i = 0
>   while True:
>     report_memory(i)
>
>     fig.clear()
>     cs = bmap.contourf(xlon, ylat, xo)
>     del cs
>
>     i += 1
>
> if __name__ == '__main__': plot()
>
>   


Jesper:  For now I recommend adding 'pylab.cla()' after the fig.clear() 
as a workaround.  I don't really understand why that is necessary - 
perhaps John or Eric can clarify whether this is indeed a bug.

-Jeff

-- 
Jeffrey S. Whitaker         Phone  : (303)497-6313
Meteorologist               FAX    : (303)497-6449
NOAA/OAR/PSD  R/PSD1        Email  : [EMAIL PROTECTED]
325 Broadway                Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg


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