I have a friend who's having strange memory issues when opening and displaying images (using Matplotlib).

Here's what he says:
#######################################

pylab seems really inefficient: Opening a few images and displaying them eats up tons of memory, and the memory doesn't get freed.

Starting python, and run

In [5]: from glob import *;

In [6]: from pylab import *

python has 33MB of memory.


Run

In [7]: i = 1

In [8]: for imname in glob("*.JPG"):
  ...:     im = imread(imname)
  ...:     figure(i); i = i+1
  ...:     imshow(im)
  ...:

This opens 10 figures and displays them. Python takes 480MB of memory. This is crazy, for 10 images -- 40+MB of memory for each!

In [14]: close("all")

In [15]: i = 1

In [16]: for imname in glob("*.JPG"):
   im = imread(imname)
   figure(i); i = i+1
   imshow(im)
  ....:
  ....:

This closes all figures and opens them again. Python takes up 837MB of memory.

and so on... Something is really wrong with memory management.

##### System info: ##############

(using macosx backend)

2.4GHz MacBook Pro Intel Core 2 Duo

4GB 667MHz DDR2 SDRAM

In [5]: sys.version
Out[5]: '2.6.2 (r262:71600, Oct  1 2009, 16:44:23) \n[GCC 4.2.1 (Apple Inc. build 5646)]'

In [6]: numpy.__version__
Out[6]: '1.3.0'

In [7]: matplotlib.__version__
Out[7]: '0.99.1.1'

In [8]: scipy.__version__
Out[8]: '0.7.1'

In [9]: