AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
November 2008

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2008.11.26 15:44 "Memory leak opening and closing files?", by Eric Bruneton
2008.11.26 16:54 "Re: Memory leak opening and closing files?", by Frank Warmerdam
2008.11.26 17:13 "Re: Memory leak opening and closing files?", by Bob Friesenhahn
2008.11.27 09:35 "Re: Memory leak opening and closing files?", by Eric Bruneton
2008.11.27 10:22 "Re: Memory leak opening and closing files?", by <jcupitt@gmail.com>

2008.11.26 15:44 "Memory leak opening and closing files?", by Eric Bruneton

Hi,

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)