Hi,

I have a script that creates and saves figures in a loop. The memory is 
increasing at each figure and is not released back, rising a Memory error.
I used the close() function on the figure object as well as gc.collect(), but 
no effect.

I searched on the net and found a similar problem at 
http://stackoverflow.com/questions/3623600/python-matplotlib-memory-not-being-released-when-specifying-figure-size.
 The problem here was solved using the close() function but in my case, as 
refered before, it doens't work (see code below). 

I'm using Python 2.6.6, matplotlib 1.0.1, WXagg as backend, on windows7.

Thanks for help!

Alain


CODE:

import pylab as pl
import os, tempfile
def plot_density(filename,i,t,psi_Na):
    pl.figure(figsize=(8,6))
    pl.imshow(abs(psi_Na)**2,origin = 'lower')
    filename = os.path.join(tempfile.gettempdir(), filename + '_%04d.png'%i)
    pl.savefig(filename)
    pl.clf()
    pl.close()
if __name__ == "__main__":
    x = pl.linspace(-6e-6,6e-6,128,endpoint=False)
    y = pl.linspace(-6e-6,6e-6,128,endpoint=False)
    X,Y = pl.meshgrid(x,y)
    k = 1000000
    omega = 200
    times = pl.linspace(0,100e-3,100,endpoint=False)
    for i,t in enumerate(times):
        import pylab as pl
        psi_Na = pl.sin(k*X-omega*t)
        plot_density('wavefunction',i,t,psi_Na)
        print i
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to