Page 1 of 1

Memory leak by MagickWand?

Posted: 2011-05-15T22:50:20-07:00
by dcming
When I use MagickSetImageCompressionQuality convert image many many times,I find memory leak.
The code like this:

Code: Select all

{
        char *blob;
        size_t new_image_size;

        MagickWandGenesis();
        magick_wand = NewMagickWand();

        status = MagickReadImageBlob(magick_wand,image_buf,buf_len);
        if (status == MagickFalse){
            LogWandException(magick_wand);
        }

        //MagickSetImageCompressionQuality(magick_wand,70);

        DestroyMagickWand(magick_wand);
        MagickWandTerminus();       
}
Runtime is: windows xp/windows server 2003 ,visual studio C++ 2005
Imagick version is:latest version ImageMagick-6.6.9-9-Q16-windows-dll

If i comment MagickSetImageCompressionQuality,everything is Ok!
But if uncomment MagickSetImageCompressionQuality,after many many times ,I found the virtual memory of my program continues to grow.
I use memory tool VMMap and VC found some traces of memory leak,like this
0x0CA30000 08 00 00 00 00 01 00 05 ee ff ee ff 00 00 00 00 00 00 e1 00 00 10 00 00 00 00 a3 0c 00 .............................
0x0CA3001D 10 00 00 40 00 a3 0c 00 00 a3 0d 04 00 00 00 04 00 00 00 50 00 79 06 00 00 00 00 40 00 ...@...............P.y.....@.
0x0CA3003A a3 0c 00 00 00 00 04 02 08 00 ba 07 1c 05 4a 50 45 47 00 f0 ad ba 0d f0 ad ba 0d f0 ad ..............JPEG...........
0x0CA30057 ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba .............................
0x0CA30074 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d .............................
0x0CA30091 f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 .............................
0x0CA300AE ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad .............................
0x0CA300CB ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba .............................
0x0CA300E8 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0 ad ba 0d f0

There are many 0xBAADF00D in memory,I found the difination of 0xBAADF00D is:
0xBAADF00D Bad Food Memory allocated by LocalAlloc() with LMEM_FIXED, but not yet written to.

At the end of the process,magick_wand is destoryed ,and then call MagickWandTerminus,everything is cleand out.
Why there is 0xBAADF00D?,Is Memory leak of imagick???