Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas035.isp.belgacom.be (localhost [127.0.0.1])
        by inav005.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k9P92M2J003886
        for <joris.at.lebbeke@skynet.be>; Wed, 25 Oct 2006 11:02:22 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx002.isp.belgacom.be (inmx002.isp.belgacom.be [195.238.5.7])
	by inas035.isp.belgacom.be (Postfix) with ESMTP id 399D554C058
	for <joris.at.lebbeke@skynet.be>; Wed, 25 Oct 2006 11:02:21 +0200 (CEST)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx002.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id k9P929M5006435
        for <joris.at.lebbeke@skynet.be>; Wed, 25 Oct 2006 11:02:10 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k9P8miGU023014;
	Wed, 25 Oct 2006 04:49:33 -0400
Received: from smtp105.plus.mail.mud.yahoo.com
	(smtp105.plus.mail.mud.yahoo.com [68.142.206.238])
	by duke.maptools.org (8.12.11/8.12.10) with SMTP id k9P8mePT023011
	for <tiff@lists.maptools.org>; Wed, 25 Oct 2006 04:48:40 -0400
Message-Id: <200610250848.k9P8mePT023011@duke.maptools.org>
Received: (qmail 67979 invoked from network); 25 Oct 2006 08:48:23 -0000
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com;
	h=Received:X-MSReally-From:From:To:Subject:Date:MIME-Version:Content-Type:X-Mailer:X-MimeOLE:Thread-Index;
	b=Pr6YHYxhd53yDFON1re9WGoeMlxfI99b53jf+mcNGLKGiI4Uf1PGJfKg0/XDnOkSxCLQj0XsDTuHIDXRK7xexIseaHO8Hik/QFV2UfhX6OQMu8kBj3Pb7/Oj1QhxWoT+E7HKVY//OoS+V26yB/BaL/Rp2tbZ+1La5peeuMlob9w=
	; 
Received: from unknown (HELO AmarsLaptop) (amarnaths?vjt@125.22.5.212 with
	login)
	by smtp105.plus.mail.mud.yahoo.com with SMTP; 25 Oct 2006 08:48:22 -0000
X-MSReally-From: amarnaths_vjt@yahoo.com
From: "Amarnath S" <amarnaths_vjt@yahoo.com>
To: <tiff@lists.maptools.org>
Date: Wed, 25 Oct 2006 14:18:16 +0530
MIME-Version: 1.0
X-Mailer: Microsoft Office Outlook, Build 11.0.5510
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962
Thread-Index: Acb4ElA1Spo4UgK7QqC/UsroNRPVvw==
Subject: [Tiff] Newbie Question on Memory Usage within LibTiff
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1591964204=="
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00001c82
X-MSP-STORE: Wed, 25 Oct 2006 11:02:31 +0200
Status:   

This is a multi-part message in MIME format.

--===============1591964204==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_003A_01C6F840.6BEF2D30"

This is a multi-part message in MIME format.

------=_NextPart_000_003A_01C6F840.6BEF2D30
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

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-------------------------------*/
 
 

------=_NextPart_000_003A_01C6F840.6BEF2D30
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2900.2963" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006>Hi,</SPAN></FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006>&nbsp;&nbsp;&nbsp; I am&nbsp;a newcomer=20
to&nbsp;LibTiff, and to TIFF in general;&nbsp;this&nbsp;question relates =

to&nbsp;memory usage in the TIFF library. I have a simple C program to =
create a=20
TIFF file (modified slightly from its original, available on <A=20
href=3D"http://www.stillhq.com">www.stillhq.com</A>). I ran it on Visual =
C++ 6.0.=20
At&nbsp;the line marked AAAA&nbsp;in the code, the memory usage was 1404 =
K,=20
whereas at BBBB, it was 1516 K (as monitored on the Windows Task =
Manager); this=20
means that there is a memory leak somewhere.&nbsp;I am using Windows XP =
SP2. The=20
entire C program is given below.</SPAN></FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006>Now, my questions are:</SPAN></FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006>Are there any known memory issues within the =
TIFF=20
Library? I believe not, but then, what am I missing?&nbsp;Please help me =

in&nbsp;finding a remedy&nbsp;this memory usage =
issue.</SPAN></FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006>Thanks and Regards</SPAN></FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006>- Amarnath</SPAN></FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2></FONT>&nbsp;</DIV>
<DIV><SPAN class=3D372143408-25102006><FONT face=3D"MS Reference Sans =
Serif"=20
size=3D2>/*-----------------------------------CODE=20
START-----------------------------*/</FONT></SPAN></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2>#include=20
&lt;stdio.h&gt;<BR>#include "tiffio.h"</FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2>int main(int argc, =

char=20
*argv[]){<BR>&nbsp; // Define the buffer for an image which is 64 pixels =
by 32=20
pixels - 1 bit per pixel<BR>&nbsp; char buffer[8 * 32];<BR>&nbsp; TIFF=20
*image;<BR>&nbsp; int i;</FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2>&nbsp; for ( i =3D =
0; i &lt; 8 *=20
32; ++i )<SPAN class=3D372143408-25102006>&nbsp;&nbsp; /* =
------------LINE=20
AAAA--------------- */</SPAN><BR>&nbsp;&nbsp; buffer[i] =3D (i % 2) ? =
0x00 :=20
0xFF;</FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2>&nbsp; // Open the =
TIFF=20
file<BR>&nbsp; if((image =3D TIFFOpen("output.tif", "w")) =3D=3D=20
NULL){<BR>&nbsp;&nbsp;&nbsp; printf("Could not open output.tif for=20
writing\n");<BR>&nbsp;&nbsp;&nbsp; return -1;<BR>&nbsp; }</FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2>&nbsp; // Set =
values for basic=20
tags before we can add any data<BR>&nbsp; TIFFSetField(image,=20
TIFFTAG_IMAGEWIDTH, 8 * 8);<BR>&nbsp; TIFFSetField(image, =
TIFFTAG_IMAGELENGTH,=20
32);<BR>&nbsp; TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, 1);<BR>&nbsp;=20
TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, 1);<BR>&nbsp; =
TIFFSetField(image,=20
TIFFTAG_ROWSPERSTRIP, 32);</FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2>&nbsp; =
TIFFSetField(image,=20
TIFFTAG_COMPRESSION, COMPRESSION_NONE);<BR>&nbsp; TIFFSetField(image,=20
TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);<BR>&nbsp; =
TIFFSetField(image,=20
TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);<BR>&nbsp; TIFFSetField(image,=20
TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);</FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2>&nbsp; =
TIFFSetField(image,=20
TIFFTAG_XRESOLUTION, 150.0);<BR>&nbsp; TIFFSetField(image, =
TIFFTAG_YRESOLUTION,=20
150.0);<BR>&nbsp; TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT,=20
RESUNIT_INCH);<BR>&nbsp; <BR>&nbsp; // Write the information to the=20
file<BR>&nbsp; TIFFWriteEncodedStrip(image, 0, buffer, 8 * =
32);</FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2>&nbsp; // Close the =

file<BR>&nbsp; TIFFClose(image);<BR>&nbsp; return 0;<SPAN=20
class=3D372143408-25102006>&nbsp; /* ------------LINE =
BBBB---------------=20
*/</SPAN><BR>}</FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2><SPAN=20
class=3D372143408-25102006><FONT face=3D"MS Reference Sans Serif"=20
size=3D2>/*-----------------------------------CODE=20
END-------------------------------*/</FONT></SPAN></FONT></DIV>
<DIV><FONT face=3D"MS Reference Sans Serif" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"MS Reference Sans Serif"=20
size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_003A_01C6F840.6BEF2D30--


--===============1591964204==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
--===============1591964204==--
