You can try running the garbage collector after each savefig.  ("import 
gc" and then call "gc.collect()").  If you are using a GUI backend, you 
may want to try using the "raw" Agg backend instead -- there are fewer 
moving parts that way.

There have been a number of memory leaks that have been fixed since 
0.90.1.  You may want to try 0.91 or a SVN checkout to see if that fixes 
your problem.

There is additional information about memory leaks in the FAQ.  I don't 
know if any are relevant to your particular situation:

http://matplotlib.sourceforge.net/faq.html#LEAKS

If none of the above helps, please send a complete but short script that 
reproduces the error (basing it on memleak_gui.py or memleak_hawaii.py 
is even more helpful), and one of the developers can look into it.

Cheers,
Mike

Jordan Atlas wrote:
> Hi all,
> 
>     I've noticed that when I save my figures using savefig the memory is 
> not immediately released.  For example, in pseudocode,
> 
> times = get_times()
> for var_id in var_list:
>     Plotting.figure()
>     var_values = get_values(var_id)
>     pylab.plot(times, values)
>     Plotting.savefig(var+'.png', dpi=150)
>     Plotting.close()
> 
> This pseudo code loops over a list of variables, gets their values, and 
> saves a plot for each one.  The variable list has hundreds of items.  If 
> I run the code like this, the memory usage grows very quickly until 
> python crashes.  If I comment out the savefig line, or shorten the list 
> of variables, the code completes without error.
> 
> Can anyone suggest how I might write this differently so that I can 
> process the long list of variables and save the figures?  Is there any 
> way to force the program to release memory once the figures are saved?
> 
> I'm using matplotlib 0.90.1 and python 2.4 on windows XP.
> 
> Thank you,
> 
> --Jordan Atlas
> 
> 
> -------------------------------------------------------------------------
> SF.Net email is sponsored by: The Future of Linux Business White Paper
> from Novell.  From the desktop to the data center, Linux is going
> mainstream.  Let it simplify your IT future.
> http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to