No memory released after reading one image
Posted: 2009-10-10T14:57:57-07:00
I'm using 6.5.6-9 and the MagickCore api. It seems that the memory is not being released after reading one image. I used the following code:
When running the executable the memory usage keeps growing and growing until all the images (size: ~3000x2000) are processed. After processing 50 images the mem usage is already at 1.750.000. It drops back to 486.000 when the program is ready. It this a bug, or should i change the code?
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <magick/MagickCore.h>
#include <windows.h>
void main(int argc, char *argv[])
{
ExceptionInfo *exception;
Image *image, *images, *resize_image;
ImageInfo *image_info;
char BUF[256];
int j;
for (j=1; j<65; j++) {
sprintf(BUF, "001-%03d.jpg", j);
OutputDebugString(BUF);
MagickCoreGenesis(argv[1], MagickTrue);
image_info = CloneImageInfo((ImageInfo *) NULL);
exception = AcquireExceptionInfo();
(void) strcpy(image_info->filename, BUF);
images = ReadImage(image_info, exception);
images = CoalesceImages(images, exception);
image = GetImageFromList(images, 0);
resize_image = ResizeImage(image,640,480,LanczosFilter,1.0,exception);
// Write the image thumbnail
(void) strcpy(resize_image->filename, "thumbnail.JPG");
WriteImage(image_info, resize_image);
DestroyImage(image);
DestroyImage(resize_image);
DestroyImageInfo(image_info);
DestroyExceptionInfo(exception);
MagickCoreTerminus();
}
}