memory problem

Hi,

on a pc with linux and 512M of RAM, I have a problem of memory when I'm using matplotlib.

from pylab import *
imshow(zeros((2000,2000)))
show()

is working but:

from pylab import *
imshow(zeros((4000,4000)))
show()

is not.

That slow down the computer, it close to be freeze and I obtain this error (the two error message for show() and savefig('test.png') are at the bottom of the mail. (matshow give exactly the same result)

It's a big problem, for me at least, because I'm working with some image with 4000x4000 pixels.

Thanks,

       N.

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python2.4/lib-tk/Tkinter.py", line 1345, in __call__
    return self.func(*args)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py", line 140, in resize
    self.show()
  File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py", line 143, in draw
    FigureCanvasAgg.draw(self)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 312, in draw
    self.figure.draw(renderer)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/figure.py", line 395, in draw
    for a in self.axes: a.draw(renderer)
  File "/scratch/gruel/usr/local/lib/python2.4/site-packages/matplotlib/axes.py", line 1339, in draw
    im.draw(renderer)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/image.py", line 182, in draw
    im = self.make_image(isUpper)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/image.py", line 112, in make_image
    x = self.to_rgba(self._A, self._alpha)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/cm.py", line 418, in to_rgba
    return self.cmap(x, alpha)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/colors.py", line 526, in __call__
    rgba = zeros(xa.shape+(4,), Float)
  File "/usr/local/lib/python2.4/site-packages/numarray/numarraycore.py", line 1407, in zeros
    retarr = NumArray(shape=shape, type=type)
MemoryError: Couldn't allocate requested memory

I did the same with savefig

Traceback (most recent call last):
  File "test.py", line 12, in ?
    savefig('test.png')
  File "/scratch/gruel/usr/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 719, in savefig
    return fig.savefig(*args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/figure.py", line 512, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py", line 161, in print_figure
    agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 375, in print_figure
    self.draw()
  File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 312, in draw
    self.figure.draw(renderer)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/figure.py", line 395, in draw
    for a in self.axes: a.draw(renderer)
  File "/scratch/gruel/usr/local/lib/python2.4/site-packages/matplotlib/axes.py", line 1339, in draw
    im.draw(renderer)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/image.py", line 182, in draw
    im = self.make_image(isUpper)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/image.py", line 112, in make_image
    x = self.to_rgba(self._A, self._alpha)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/cm.py", line 418, in to_rgba
    return self.cmap(x, alpha)
  File "/usr/local/lib/python2.4/site-packages/matplotlib/colors.py", line 526, in __call__
    rgba = zeros(xa.shape+(4,), Float)
  File "/usr/local/lib/python2.4/site-packages/numarray/numarraycore.py", line 1407, in zeros
    retarr = NumArray(shape=shape, type=type)
MemoryError: Couldn't allocate requested memory

It's clear you are running out of memory. The image you are displaying is on the order of 64MB in size. While the single array itself isn't enough to consume all your memory, it isn't clear what other memory is in use, or what your page size is, etc. Matplotlib will create some temporaries in the process of scaling arrays for display, so I wouldn't be surprised to see this image require a few more times that amount of memory.

Perry

···

On Apr 1, 2005, at 9:51 AM, Humufr wrote:

                   Hi,

on a pc with linux and 512M of RAM, I have a problem of memory when I'm using matplotlib.

from pylab import *
imshow(zeros((2000,2000)))
show()

is working but:

from pylab import *
imshow(zeros((4000,4000)))
show()

is not.

That slow down the computer, it close to be freeze and I obtain this error (the two error message for show() and savefig('test.png') are at the bottom of the mail. (matshow give exactly the same result)

It's a big problem, for me at least, because I'm working with some image with 4000x4000 pixels.

Thanks,

      N.

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/local/lib/python2.4/lib-tk/Tkinter.py", line 1345, in __call__
   return self.func(*args)
File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py", line 140, in resize
   self.show()
File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py", line 143, in draw
   FigureCanvasAgg.draw(self)
File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 312, in draw
   self.figure.draw(renderer)
File "/usr/local/lib/python2.4/site-packages/matplotlib/figure.py", line 395, in draw
   for a in self.axes: a.draw(renderer)
File "/scratch/gruel/usr/local/lib/python2.4/site-packages/matplotlib/axes.py", line 1339, in draw
   im.draw(renderer)
File "/usr/local/lib/python2.4/site-packages/matplotlib/image.py", line 182, in draw
   im = self.make_image(isUpper)
File "/usr/local/lib/python2.4/site-packages/matplotlib/image.py", line 112, in make_image
   x = self.to_rgba(self._A, self._alpha)
File "/usr/local/lib/python2.4/site-packages/matplotlib/cm.py", line 418, in to_rgba
   return self.cmap(x, alpha)
File "/usr/local/lib/python2.4/site-packages/matplotlib/colors.py", line 526, in __call__
   rgba = zeros(xa.shape+(4,), Float)
File "/usr/local/lib/python2.4/site-packages/numarray/numarraycore.py", line 1407, in zeros
   retarr = NumArray(shape=shape, type=type)
MemoryError: Couldn't allocate requested memory

I did the same with savefig

Traceback (most recent call last):
File "test.py", line 12, in ?
   savefig('test.png')
File "/scratch/gruel/usr/local/lib/python2.4/site-packages/matplotlib/pylab.py", line 719, in savefig
   return fig.savefig(*args, **kwargs)
File "/usr/local/lib/python2.4/site-packages/matplotlib/figure.py", line 512, in savefig
   self.canvas.print_figure(*args, **kwargs)
File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_tkagg.py", line 161, in print_figure
   agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)
File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 375, in print_figure
   self.draw()
File "/usr/local/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py", line 312, in draw
   self.figure.draw(renderer)
File "/usr/local/lib/python2.4/site-packages/matplotlib/figure.py", line 395, in draw
   for a in self.axes: a.draw(renderer)
File "/scratch/gruel/usr/local/lib/python2.4/site-packages/matplotlib/axes.py", line 1339, in draw
   im.draw(renderer)
File "/usr/local/lib/python2.4/site-packages/matplotlib/image.py", line 182, in draw
   im = self.make_image(isUpper)
File "/usr/local/lib/python2.4/site-packages/matplotlib/image.py", line 112, in make_image
   x = self.to_rgba(self._A, self._alpha)
File "/usr/local/lib/python2.4/site-packages/matplotlib/cm.py", line 418, in to_rgba
   return self.cmap(x, alpha)
File "/usr/local/lib/python2.4/site-packages/matplotlib/colors.py", line 526, in __call__
   rgba = zeros(xa.shape+(4,), Float)
File "/usr/local/lib/python2.4/site-packages/numarray/numarraycore.py", line 1407, in zeros
   retarr = NumArray(shape=shape, type=type)
MemoryError: Couldn't allocate requested memory

-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/info/Sentarus/hamr30
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users