[Magick-bugs] It seems there is a memory leak.
Evgeny Rippi
repekto.argosoft at gmail.com
Mon May 28 23:52:46 PDT 2007
Hi ImageMagick users,
I created a small program and intentionally added an exception
situation. I'm using ImageMagick that is set to use the Windows
registry. I have changed the registry record from Q:8 to Q:81, as such
ImageMagick can not work properly because it can not find the modules.
I've created the loop where I convert the image. And the exception
occurs in the Image()
constructor.
The code:
#include <Magick++.h>
using namespace std;
using namespace Magick;
namespace EngineR
{
namespace Converter
{
Blob result;
std::string errorMessage;
int Convert(void* data, int length,
pConstVoid& convData, int &width, int &height, int& convLength)
{
try
{
Blob blob(data, length);
Magick::Image image(blob); // in this point the exception occurs:
"ImageMagick: RegistryKeyLookupFailed `CoderModulesPath'"
// write data
image.write(&result, "JPG");
convData = result.data();
convLength = result.length();
// image dimensions
width = image.size().width();
height = image.size().height();
return 0;
}
catch( Magick::Error &error )
{
errorMessage = error.what(); // then it comes here
return 1;
}
catch( std::exception &error )
{
errorMessage = error.what();
return 1;
}
catch(...)
{
errorMessage = "unknown error occured";
return 1;
}
}
const char* GetLastErrorDescription()
{
return errorMessage.c_str();
}
};
};
#include <iostream>
#include <fstream>
using namespace std;
void main()
{
ifstream file ("dsc.jpg", ios::in|ios::binary|ios::ate);
ifstream::pos_type size;
char * memblock;
const void* convData;
int convLength;
int width, height;
// open the file to be converted
if (file.is_open())
{
size = file.tellg();
memblock = new char [size];
file.seekg (0, ios::beg);
file.read (memblock, size);
file.close();
}
for (int i=0; i<100000; i++)
{
EngineR::Converter::Convert(memblock, size, convData, convLength,
width, height);
std::cout << "i=" << i << std::endl;
}
}
So, the memory a little leaks during the iterations as it shows
windows task manager.
Please, check it out is it really a bug or I missed something out?
Evgeny.
More information about the Magick-bugs
mailing list