Page 1 of 1

Memory loss using getPixels

Posted: 2008-12-06T07:54:27-07:00
by ptast
FYI

I just installed (compiled from source 6.4.7-1) ImageMagick on the F9 1gb machine and it eat up all memory FAST and finally Seg faulted (ofcource) after < 10 images. I did not change my code.

So there is a big difference running 6.4.5-7 and latest. Let me know if you want a valgrind shot and me to search closer in IM code?

Sample stuff (gray at the moment...)
http://noaaport.poes-weather.com:8081/n ... ber&day=06

Click on the View reports btn
Patrik

Hi all,

Perhaps this is fixed in the latest version?

I'm using Magick++ 6.4.6-8 Fedora 9 QuantumDepth 8

I have a gray scale image and colour it using a clut (colour lookup table) loaded from file (wxh) 100x256 px.

When ever I call p = clut->getPixels(x, y, 1, 1); the memory increses. When I later delete the clut nothing is freed. The memory loss is so huge so after colouring round 50 5120x5120 images it have eaten up all my ram, 4gb. Ive also tried function pixelColor(...), constPixels(...) with the same result.

I installed the same software on a F9 1gb ram using IM 6.4.5-7 and it can create infinitely the same images without loosing any memory.

Code: Select all

  image = new Image(Geometry(Nx, Ny), "black");
  image->modifyImage();
  image->type(TrueColorType);
  
  qDebug("image w: %d h: %d", Nx, Ny);

  clut = getCLUT();

  for(y=0; y<Ny; y++) {
     if((read = fread(buff, 1, Nx, in_fp)) <= 0)
        break;
  
     p = image->getPixels(0, y, Nx, 1);  
     if(!p)
        break;

     for(x=0; x<read && x<Nx; x++, p++) {
        pixel.red   = buff[x];
        pixel.green = buff[x];
        pixel.blue  = buff[x];

        if(clut) {
           t = GrayToKelvin((double)buff[x]);
           GetHSVPixel(clut, t, &pixel);
        }

        p->red   = pixel.red;
        p->green = pixel.green;
        p->blue  = pixel.blue;
     }  
  }

  if(clut)
     delete clut;
  clut = NULL;

// getCLUT() function
....
  clut = new Image(clutfile.toStdString().c_str());

  return clut;

// GetHSVPixel function stuff
  p = clut->getPixels(x, y, 1, 1);
  if(p) {
     pixel->red   = p->red;
     pixel->green = p->green;
     pixel->blue  = p->blue;
     // qDebug("lutPixels OK");
  }
  else
     qDebug("clutPixels failed x: %d y: %d", x, y);


Re: Memory loss using getPixels

Posted: 2008-12-06T09:49:29-07:00
by magick
We have a patch for the problem you reported. Look for the patch in ImageMagick 6.4.7-2, available later today or tomorrow.

Re: Memory loss using getPixels

Posted: 2008-12-06T09:58:06-07:00
by ptast
OH, great!!!

I'll stay tuned and report.

Many

Re: Memory loss using getPixels

Posted: 2008-12-07T04:36:16-07:00
by ptast
Hi Magick,

IM Version 6.4.7-2 sure does Magick!

Many thanks,
Patrik