Page 1 of 1

Memory leak in Image with x:root

Posted: 2012-03-06T15:05:55-07:00
by chris1234
Hi,
I'm getting a memory leak when capturing from my x desktop.
A simple example is

Code: Select all

#include <Magick++.h>

int main(int argc, char *argv[])
{
    Magick::Image img("x:root");
    return 0;
}
The output from valgrind is:

Code: Select all

==16722== 39,780 (38,712 direct, 1,068 indirect) bytes in 3 blocks are definitely lost in loss record 80 of 82
==16722==    at 0x4027199: memalign (vg_replace_malloc.c:581)
==16722==    by 0x40271F6: posix_memalign (vg_replace_malloc.c:709)
==16722==    by 0x454F21C: AcquireAlignedMemory (in /usr/lib/libMagickCore.so.3.0.0)
==16722==    by 0x45409F5: AcquireImage (in /usr/lib/libMagickCore.so.3.0.0)
==16722==    by 0x45F2435: ??? (in /usr/lib/libMagickCore.so.3.0.0)
==16722==    by 0x4607160: XImportImage (in /usr/lib/libMagickCore.so.3.0.0)
I'm running Ubuntu 11.10 with has magick++ 6.6.04 by default.
I've also built 6.7.5.10 and get the same problem. For this version valgrind reports:

Code: Select all

==29939== 65,388 (38,736 direct, 26,652 indirect) bytes in 3 blocks are definitely lost in loss record 1,341 of 1,342
==29939==    at 0x4028876: malloc (vg_replace_malloc.c:236)
==29939==    by 0x46987C5: AcquireMagickMemory (memory.c:398)
==29939==    by 0x46873BD: AcquireImage (image.c:160)
==29939==    by 0x4753BE0: XGetWindowImage (xwindow.c:4315)
==29939==    by 0x4768AE0: XImportImage (xwindow.c:5033)
Any ideas?

Thanks,
Chris

Re: Memory leak in Image with x:root

Posted: 2012-03-06T17:30:15-07:00
by magick
Thanks for the bug report. Look for a patch in ImageMagick 6.7.6-0 Beta that plugs the memory leak by sometime tomorrow.