Memory leak in pcolor?

Hi all,

Typing this (on ipython prompt with the relevant libraries imported)

x = linspace(0,1.0,500)
y = linspace(0,1.0,500)
xg,yg = meshgrid(x,y)
c = rand(len(x), len(y))
pcolor(xg,yg,c)

Makes the ipython process to grow to have about 400 Mb of resident
memory and it takes ages for the plot to appear (a 1000x1000 image
just makes my 1 Gb system trash helplessly).

But, using pcolormesh instead of pcolor in the last line of the script
above works ok, the plot appears almost immediately, and the memory
consumption of the ipython process only doubles, i.e. grows about 30
Mb.

Is this a bug or am I doing something wrong? I'm using
python-matplotlib 0.99.0-1 from Debian.

Best,

Teemu

Teemu Ikonen wrote:

Hi all,

Typing this (on ipython prompt with the relevant libraries imported)

x = linspace(0,1.0,500)
y = linspace(0,1.0,500)
xg,yg = meshgrid(x,y)
c = rand(len(x), len(y))
pcolor(xg,yg,c)

Makes the ipython process to grow to have about 400 Mb of resident
memory and it takes ages for the plot to appear (a 1000x1000 image
just makes my 1 Gb system trash helplessly).

But, using pcolormesh instead of pcolor in the last line of the script
above works ok, the plot appears almost immediately, and the memory
consumption of the ipython process only doubles, i.e. grows about 30
Mb.

Is this a bug or am I doing something wrong? I'm using
python-matplotlib 0.99.0-1 from Debian.

It is a limitation of pcolor, which uses a PolyCollection--very flexible and general, but very inefficient for simple cases with many polygons. With a regular grid, you can simply use an image, for the highest performance. pcolormesh is also a good alternative, and more general than image. There is no pyplot wrapper, but the Axes.pcolorfast method can use any of three different algorithms to achieve pcolor-like results with the highest possible efficiency for a given grid.

Eric

ยทยทยท

Best,

Teemu

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options