AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2006.10.25 08:48 "[Tiff] Newbie Question on Memory Usage within LibTiff", by Amarnath S
2006.10.25 09:21 "Re: [Tiff] Newbie Question on Memory Usage within LibTiff", by Joris
2006.10.25 15:33 "Re: [Tiff] Newbie Question on Memory Usage within LibTiff", by Edward Lam
2006.10.25 11:49 "Re: [Tiff] Newbie Question on Memory Usage within LibTiff", by Gerben Vos
2006.10.25 16:00 "Re: [Tiff] Newbie Question on Memory Usage within LibTiff", by Bob Friesenhahn

2006.10.25 08:48 "[Tiff] Newbie Question on Memory Usage within LibTiff", by Amarnath S

Hi,

    I am a newcomer to LibTiff, and to TIFF in general; this question
relates to memory usage in the TIFF library. I have a simple C program to
create a TIFF file (modified slightly from its original, available on
www.stillhq.com). I ran it on Visual C++ 6.0. At the line marked AAAA in the
code, the memory usage was 1404 K, whereas at BBBB, it was 1516 K (as
monitored on the Windows Task Manager); this means that there is a memory
leak somewhere. I am using Windows XP SP2. The entire C program is given
below.

Now, my questions are:
Are there any known memory issues within the TIFF Library? I believe not,
but then, what am I missing? Please help me in finding a remedy this memory
usage issue.

Thanks and Regards
- Amarnath

/*-----------------------------------CODE
START-----------------------------*/
#include <stdio.h>
#include "tiffio.h"

int main(int argc, char *argv[]){
  // Define the buffer for an image which is 64 pixels by 32 pixels - 1 bit
per pixel
  char buffer[8 * 32];
  TIFF *image;
  int i;

  for ( i = 0; i < 8 * 32; ++i )   /* ------------LINE AAAA---------------

*/
   buffer[i] = (i % 2)? 0x00: 0xFF;

  // Open the TIFF file
  if((image = TIFFOpen("output.tif", "w")) == NULL){
    printf("Could not open output.tif for writing\n");
    return -1;
  }

// Set values for basic tags before we can add any data

TIFFSetField(image, TIFFTAG_IMAGEWIDTH, 8 * 8);

TIFFSetField(image, TIFFTAG_IMAGELENGTH, 32);

TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 1);

TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 1);

TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, 32);

TIFFSetField(image, TIFFTAG_COMPRESSION, COMPRESSION_NONE);

TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);

TIFFSetField(image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);

TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);

TIFFSetField(image, TIFFTAG_XRESOLUTION, 150.0);

TIFFSetField(image, TIFFTAG_YRESOLUTION, 150.0);

TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH);

  // Write the information to the file
  TIFFWriteEncodedStrip(image, 0, buffer, 8 * 32);

  // Close the file
  TIFFClose(image);
  return 0; /* ------------LINE BBBB--------------- */
}
/*-----------------------------------CODE
END-------------------------------*/