Page 1 of 1

Memory leak in LevelColorsImage??

Posted: 2010-08-30T01:25:53-07:00
by jcsm
HI

I have this problem on v6.6.1 (Windows VS 9.0.30729.1 SP), this is reproducible with next source code, I tried with the deprecate function LevelImageColors with the same result, any idea?

Thank you
jcs

Code: Select all

//-------------------------------------------------------------------------------
	MagickWandGenesis();
	MagickWand *imageLeak = NewMagickWand();
	PixelWand *p1 = NULL,*p2 = NULL;
	p1 = NewPixelWand();
	p2 = NewPixelWand();
	PixelSetColor(p1, "rgb(10,10,10)");
	PixelSetColor(p2, "rgb(140,10,10)");
	MagickNewImage(imageLeak, 80, 80, p1 );
	MagickPixelPacket mp1,mp2;
	PixelGetMagickColor(p1, &mp1);
	PixelGetMagickColor(p2, &mp2);
	LevelColorsImage(imageLeak->images, &mp2, &mp1, MagickTrue ); //Memory Leak
	if (imageLeak != NULL ) 
		imageLeak = DestroyMagickWand(imageLeak );
	if (p1 != NULL ) 
		p1 = DestroyPixelWand(p1 );
	if (p2 != NULL ) 
		p2 = DestroyPixelWand(p2 );
	MagickWandTerminus();
//-------------------------------------------------------------------------------

Re: Memory leak in LevelColorsImage??

Posted: 2010-08-30T08:39:58-07:00
by el_supremo
@Magick: LevelImageChannel does an AcquireCacheView and then a DestroyCacheView before returning. But LevelizeImageChannel does an Acquire without Destroy.

Pete

Re: Memory leak in LevelColorsImage??

Posted: 2010-08-30T11:00:41-07:00
by magick
Good catch. We'll get a patch into the ImageMagick Subversion trunk sometime today. Thanks.

Re: Memory leak in LevelColorsImage??

Posted: 2010-08-30T11:10:55-07:00
by jcsm
Thank you "el_supremo", I fixed it adding next code:

if (image_view != NULL )
image_view=DestroyCacheView(image_view);