Possible memory leak for some TIFF images
Added by Fulvio Senore almost 12 years ago
As I have written in an older post I am using the Exiv2 library with an older version of Expat because wxWidgets ships with that older version.
Somebody gave me some advice: only XMP uses expat so, since I am not using it, it would be possible to exclude if in the configuration file.
Being lazy I first tried using the older expat version and everything linked and worked well.
Now, testing the Windows version of the program, the Visual C++ compiler reported al lot of memory leaks when I read some tiff files. It did not happen with other files so I discovered it only yesterday.
MSVC has some tips about finding the code location where the leaked memory blocks were allocated. I cannot be 100% sure because the allocation block numbers changed slightly from run to run, even if I did exactly the same thing, but the debugger made a break in "xmp.cpp", inside code controlled by
#ifdef EXV_HAVE_XMP_TOOLKIT
so it is executed only if xmp is enabled. Moreover the leaked memory blocks contained strings like "http://www.adobe" and "http://www.digikam".
I undefined EXV_HAVE_XMP_TOOLKIT and I rebuilt the library: now I do not have memory leaks any more.
This is rather curious, and I am not even sure that this can be tracked down to an older expat library.
I realize that these information are vague and probably not very useful, but if anybody wants to make some test I can upload one image that causes the trouble to a web site.
Fulvio Senore
Replies (3)
RE: Possible memory leak for some TIFF images - Added by Andreas Huggel almost 12 years ago
Hi Fulvio,
If you can provide the steps to reproduce the problem with a sample image and reproducer program if necessary I'll try it here with the current trunk version and the correct expat. I'd do the test on Linux using valgrind to check for memory leaks as usual.
Thanks,
Andreas
RE: Possible memory leak for some TIFF images - Added by Fulvio Senore almost 12 years ago
Hi Andreas,
sorry for the delay but I needed to find some free time. The program is a rather large one and it uses a lot of libraries, so reducing it was not simple. Anyway, I did it and the reduced program does not have any memory leak. I think that I have ported the code that calls exiv2 but probably there are hidden interactions. This is bad news, of course.
In my program the leak goes away if I comment out the readMetadata() call, but I really don't know why the reduced sample works ok.
I can still send you a sample image, in case that you can inspect it and see if there are strange things. It is created by Photoshop CS4, so it should not be a strange one anyway.
The program is open source, so you might build and debug it, but it uses wxWidgets and the Firebird database (it is an image cataloger) so building it is not straightforward and it would require some time. Moreover I observed the leaks under Windows in two different computers, but I cannot be sure that the Linux version would have leaks too.
Fulvio
RE: Possible memory leak for some TIFF images - Added by Andreas Huggel almost 12 years ago
sorry for the delay but I needed to find some free time.
No problem, I know exactly what you mean :)
[...]
The program is open source, so you might build and debug it, but it uses wxWidgets and the Firebird database (it is an image cataloger) so building it is not straightforward and it would require some time. Moreover I observed the leaks under Windows in two different computers, but I cannot be sure that the Linux version would have leaks too.
I won't be able to debug any other program, not even on Linux. See above... If the memory leaks cannot be reproduced with Exiv2 alone (also try your reproducer with Valgrind on Linux), it may be a problem of the application that uses Exiv2, which only shows when readMetadata() is called, possibly because that function itself triggers many memory allocation and deallocation calls.
Andreas