| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2008.11.26 15:44 "Memory leak opening and closing files?", by Eric BrunetonHi,
the following program shows a constant increase in memory usage, so I
suspect a memory leak in the tiff library (using libtiff 3.8.2-1 on
Windows):
for (int i = 0; i < 1000000; ++i) {
TIFF *f = TIFFOpen("test.tiff", "rb");
TIFFClose(f);
}
where "test.tiff" is generated with (in fact I observed this behavior
with many different test files):
unsigned char* tile = new unsigned char[32 * 32];
for (int i = 0; i < 32 * 32; ++i) {
tile[i] = (i + i/32)%2 * 255;
}
TIFF* f = TIFFOpen("test.tiff", "wb");
TIFFSetField(f, TIFFTAG_IMAGEWIDTH, 32);
TIFFSetField(f, TIFFTAG_IMAGELENGTH, 32);
TIFFSetField(f, TIFFTAG_SAMPLESPERPIXEL, 1);
TIFFSetField(f, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(f, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
TIFFSetField(f, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT);
TIFFSetField(f, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(f, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
TIFFWriteEncodedStrip(f, 0, tile, 32 * 32);
TIFFClose(f);
note that this program:
for (int i = 0; i < 1000000; ++i) {
FILE *f = fopen("test.tiff", "rb");
fclose(f);
}
does not show this behavior.
Eric
PS I tried calling _TIFFfree((void*) TIFFFileName(f)); before TIFFClose
(it seems this is not done in TIFFClose). It does not crash, but it does
not solve the problem (memory usage still increasing with time)
|
|||||||