Slow down - memory resource increase
"Stefan v. Wachter" <[email protected]> Fri, 01 Apr 2005 17:15:36 +0200
| Newsgroups | gmane.comp.video.graphicsmagick.apis |
|---|---|
| Message-ID | <[email protected]> |
After modifying the drawtest sample (see code below) and watching the
event log (with "resource" switched on) I notice the same behaviour as
in our Tcl/Tk GM App: The memory resource increases permanently because
some amount is not freed correctly but there is no memory leak seen from
the operating system. The (windows) taskmanager shows permanently about
12 MB occupied RAM for the drawtest process.
So it looks like the calls to AcquireMagickResource and
LiberateMagickResource are not in balance. I tried the same on Linux and
in contrary to my previous experience it showed the same result.
Stefan
excerpt from drawtest.c
int main ( int argc, char **argv )
{
Image *theImage = (Image *)NULL;
char infile[MaxTextExtent];
int rows, columns = 0;
char size[MaxTextExtent];
ImageInfo *image_info;
ExceptionInfo exception;
char dummyChar;
ImageType dummyImageType, i, ii;
char* outfile = "outImageTemp.tga";
char* theFont = "Arial";
char* fillColor = "black";
double fontSize = 14;
int xPos = 20;
int yPos = 30;
char* theText = "TestText45897";
DWORD dwStartTicks = 0;
DWORD dwFinishTicks = 0;
DWORD nTicksPer10Frames = 0;
DrawContext drawContext = NULL;
if ( argc != 2 )
{
(void) printf ( "Usage: %s filename\n", argv[0] );
exit( 1 );
}
(void) strncpy( infile, argv[1], MaxTextExtent-1 );
if (LocaleNCompare("drawtest",argv[0],7) == 0)
InitializeMagick((char *) NULL);
else
InitializeMagick(*argv);
for ( i = 0; i < 1000; i++) {
dwStartTicks = GetTickCount();
for ( ii = 0; ii < 10; ii++) {
// Read image
image_info=CloneImageInfo((ImageInfo*)NULL);
GetExceptionInfo( &exception );
(void) strcpy( image_info->filename, infile);
theImage = ReadImage ( image_info, &exception );
if (exception.severity != UndefinedException)
CatchException(&exception);
if ( theImage == (Image *)NULL )
{
printf ( "Failed to read image %s\n", image_info->filename );
exit(1);
}
drawContext = DrawAllocateContext ( NULL, theImage );
DrawSetStrokeColorString (drawContext, fillColor);
DrawSetStrokeWidth (drawContext, 1);
DrawSetFont( drawContext, AllocateString (theFont));
DrawSetFontSize( drawContext, fontSize);
DrawAnnotation ( drawContext, xPos , yPos, (unsigned char*)theText );
DrawRender(drawContext);
DrawDestroyContext(drawContext);
SetImageAttribute(theImage,"[MVG]",0);
/*
* Save image to file
*/
(void) strncpy( theImage->filename, outfile,
sizeof(image_info->filename)-1);
WriteImage ( image_info, theImage );
DestroyExceptionInfo( &exception );
DestroyImage( theImage );
DestroyImageInfo( image_info );
}
dwFinishTicks = GetTickCount();
nTicksPer10Frames = dwFinishTicks - dwStartTicks;
printf ( "loop: %i; nTicksPer10Frames %i\n", i, nTicksPer10Frames);
}
dummyChar = getchar();
DestroyMagick();
return 0;
}
GraphicsMagick Event Log on Windows:
20050401112627 0:01 0.563 204 resource.c unknown 487 Resource Event
memory -3mb/0mb/894mb
20050401112627 0:01 0.563 204 resource.c unknown 143 Resource Event
memory +3mb/4mb/894mb
20050401112627 0:01 0.594 204 resource.c unknown 487 Resource Event
memory -3mb/1mb/894mb
20050401112627 0:01 0.594 204 resource.c unknown 143 Resource Event
memory +3mb/5mb/894mb
20050401112627 0:01 0.641 204 resource.c unknown 487 Resource Event
memory -3mb/1mb/894mb
20050401112627 0:01 0.641 204 resource.c unknown 143 Resource Event
memory +3mb/5mb/894mb
20050401112627 0:01 0.672 204 resource.c unknown 487 Resource Event
memory -3mb/2mb/894mb
20050401112627 0:01 0.672 204 resource.c unknown 143 Resource Event
memory +3mb/6mb/894mb
20050401112627 0:01 0.734 204 resource.c unknown 487 Resource Event
memory -3mb/2mb/894mb
20050401112627 0:01 0.734 204 resource.c unknown 143 Resource Event
memory +3mb/6mb/894mb
20050401112627 0:01 0.766 204 resource.c unknown 487 Resource Event
memory -3mb/3mb/894mb
20050401112627 0:01 0.766 204 resource.c unknown 143 Resource Event
memory +3mb/7mb/894mb
-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/Info/Sentarus/hamr30