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