Stack overflow resizing many images
Posted: 2011-10-17T11:20:19-07:00
I'm running into a stack overflow using Magick++ within a native Visual C++ application (NT service). The crash occurs when I attempt to resize a large number of images (hundreds to thousands), one after another. Eventually, the process crashes with a stack overflow at the first line of the code below. I tried both using new/delete instead as well as static vs dynamic linking, they all seems to end up eventually crashing with a stack overflow.
The code in use is:
The code above is /not/ called within a loop, it's a function that's called repeatedly by a client continuing to make requests. This is Visual C++ 10 (Visual Studio 2010) and both the application and ImageMagick are built with it (I'm building ImageMagick myself using VisualMagick). The application is running as a Windows service and links with Ole32.lib;Advapi32.lib;BugTrapU.lib;libxml2.lib;CORE_DB_Magick++_.lib.
Any help would be appreciated.
The code in use is:
Code: Select all
try
{
Magick::Image img(Magick::Blob(cacheImage->data, cacheImage->size));
img.scale(Magick::Geometry(width, height));
Magick::Blob blob;
img.write(&blob);
size = blob.length();
*data = (uint8_t*)memdup(blob.data(), size);
}
catch(Magick::Exception& e)
{
eprintf("Magick++ threw exception: %hs", e.what());
}
Any help would be appreciated.