[Matplotlib-users] Memory trouble with imshow

2008-02-19 Thread Leif Oppermann
Dear all,

I ran into a memory problem when trying to draw a few hundred png files 
using one imshow per file. The problem can be boiled down to the 
attached code which eats my memory very quickly until Python bombs out. 
I tried to del objects after their use, looked for garbage and read 
the user manual, but no luck. Did I do anything wrong or is this a 
memory leak?

Cheers,
Leif

# discovered odd behaviour in relation to the imshow function
# memory usage will go up quickly until the runtime breaks
# watch it with the task manager

# lxo, 19.02.2008
# running matplotlib-0.91.2.win32-py2.5.exe with wxPython 2.8.4.0 on 
Python 2.5.1

from pylab import *
import gc
for i in range (1000):
   A=rand(1024,1024)
   im = imshow(A)
   #del A #doesn't help
   #del im #doesn't help
   #print gc.garbage # no garbage

This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Memory trouble with imshow

2008-02-19 Thread John Hunter
On Feb 19, 2008 8:37 AM, Leif Oppermann [EMAIL PROTECTED] wrote:

 from pylab import *
 import gc
 for i in range (1000):
A=rand(1024,1024)
im = imshow(A)
#del A #doesn't help
#del im #doesn't help
#print gc.garbage # no garbage

matplotlib overplots by default -- try setting

  hold(False)

before your loop, and call gc.collect() occassionally

eg

  if (i%100)==0: gc.collect()

JDH

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users