strange memory leak report

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
jstph
Posts: 31
Joined: 2011-01-27T10:07:43-07:00
Authentication code: 8675308

strange memory leak report

Post by jstph »

Magick, I experienced a strange memory leak report.

I create an empty main method.

Code: Select all

#include "stdafx.h"
#include "magick/MagickCore.h"
#include <tchar.h>
#include "vld.h"

int _tmain(int argc, _TCHAR* argv[])
{
	return 0;
}
stdafx.h is empty.
vld.h is memory leak detector.

when run in the debug mode, it reports memory leak from glib.

my IM build is 6.8.8, muti-thread static lib.
my OS is windows 8
my IDE is MS visual studio 2010.

I used _CrtDumpMemoryLeaks originally, and it reports memory leak. I thought it may be false report. So I installed vld and it reports same thing. I checked my build setting, doesn't seem like there is anything conflicted. I posted one of the leak trace. The rest are similar, basically any memory allocated by glib will be reported as leak. I have no idea what I did wrong, hope you can shed some light no. Thanks in advance.

Call Stack:
  • f:\dd\vctools\crt_bld\self_x86\crt\src\dbgcalloc.c (56): calloc
    d:\plugins\image\imagemagick-windows\imagemagick-6.8.8\glib\glib\gmem.c (134): g_malloc0
    d:\plugins\image\imagemagick-windows\imagemagick-6.8.8\glib\gobject\gtype.c (1121): type_data_make_W
    d:\plugins\image\imagemagick-windows\imagemagick-6.8.8\glib\gobject\gtype.c (2755): g_type_register_static
    d:\plugins\image\imagemagick-windows\imagemagick-6.8.8\glib\gobject\gparam.c (1431): g_param_type_register_static
    d:\plugins\image\imagemagick-windows\imagemagick-6.8.8\glib\gobject\gparamspecs.c (1477): _g_param_spec_types_init
    d:\plugins\image\imagemagick-windows\imagemagick-6.8.8\glib\gobject\gtype.c (4401): gobject_init_ctor
    d:\plugins\image\imagemagick-windows\imagemagick-6.8.8\glib\gobject\gtype.c (4313): gobject_init_ctor_wrapper
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0dat.c (873): _initterm
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0dat.c (288): _cinit
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (262): __tmainCRTStartup
    f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (189): wmainCRTStartup
    0x76E5850D (File and line number not available): BaseThreadInitThunk
    0x77D5BF39 (File and line number not available): RtlInitializeExceptionChain
    0x77D5BF0C (File and line number not available): RtlInitializeExceptionChain
    Data:
    40 15 8C 05 28 00 00 00 00 00 00 00 00 00 00 00 @...(... ........
    00 00 00 00 B0 33 2F 01 00 00 00 00 E0 97 9E 05 .....3/. ........
    00 00 00 00 28 00 00 00 04 00 00 00 E0 AA 2B 01 ....(... ......+.
jstph
Posts: 31
Joined: 2011-01-27T10:07:43-07:00
Authentication code: 8675308

Re: strange memory leak report

Post by jstph »

I did a little bit research on this issue. It looks like Glib will release its memory block at the exit time, which probably after the vld memory check and _crt call. If that is the case, those memory allocated by Glib would be considered as leak. I read into Glib source code, it seems like Valgrind has similar problem, so Glib add special code to turns some part off for Valgrind.
Post Reply