Page 1 of 1

Memory leak in Image::ping()?

Posted: 2007-12-07T13:14:34-07:00
by Angus
I'm using the Suse rpm 6.3.0.0-27.8 for Magick++, and valgrind is reporting a memory leak, and I want to know if my code is right before making a bug report.
My code intends to simply get the dimensions of a an image file, and detect CMYK colourspace, and this is the code that does it:
Magick::Blob blob;
Magick::Image image;
try {
image.ping(sPath);
} catch (exception &ex) {
g_pLog->LogLine(ex.what());
return FALSE;
}
if (image.columns() <= 0 || image.rows() <= 0) return FALSE;
nWidth = image.columns();
nHeight = image.rows();
bCMYK = image.colorSpace() == Magick::CMYKColorspace;

That is all the Magick calls in my code. Valgrind alerts to this memory leak:
==2381== at 0x4C22AC6: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==2381== by 0x5398AF8: GetCacheInfo (in /usr/lib64/libMagick.so.10.0.5)
==2381== by 0x5411567: AllocateImage (in /usr/lib64/libMagick.so.10.0.5)
==2381== by 0x1579A0DC: (within /usr/lib64/ImageMagick-6.3.0/modules-Q16/coders/jpeg.so)
==2381== by 0x53B643C: ReadImage (in /usr/lib64/libMagick.so.10.0.5)
==2381== by 0x545C07A: ReadStream (in /usr/lib64/libMagick.so.10.0.5)
==2381== by 0x53B7321: PingImage (in /usr/lib64/libMagick.so.10.0.5)
==2381== by 0x4E78317: Magick::Image::ping(std::string const&) (in /usr/lib64/libMagick++.so.10.0.5)
Is this a real bug, or is there something wrong w/my code?

Re: Memory leak in Image::ping()?

Posted: 2007-12-07T13:32:55-07:00
by magick
We tried your program with ImageMagick 6.3.7-3, the latest release and it returns:

==22671== definitely lost: 0 bytes in 0 blocks.

Re: Memory leak in Image::ping()?

Posted: 2007-12-10T08:42:48-07:00
by Angus
Then I guess you aren't interested in a bug report, but my code is correct. I guess I'll have to dump the Suse RPMs and get the latest source, since this method loses a couple of kb w/each call.