Return-Path: <tiff-bounces@lists.maptools.org>
Received: from infbas006.isp.belgacom.be (localhost [127.0.0.1])
        by inav023.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k9PGFTcJ015548
        for <joris.at.lebbeke@skynet.be>; Wed, 25 Oct 2006 18:15:33 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inas020.isp.belgacom.be (inas020.isp.belgacom.be [195.238.4.133])
        by infbas006.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id k9PGElQm002486
        for <joris.at.lebbeke@skynet.be>; Wed, 25 Oct 2006 18:14:47 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx003.isp.belgacom.be (inmx003.isp.belgacom.be [195.238.5.11])
        by inas020.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AS-2.03) with ESMTP id k9PGEc8h002553
        for <joris.at.lebbeke@skynet.be>; Wed, 25 Oct 2006 18:14:42 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx003.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id k9PGEYA4025850
        for <joris.at.lebbeke@skynet.be>; Wed, 25 Oct 2006 18:14:35 +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 k9PG4oJ6029432;
	Wed, 25 Oct 2006 12:05:08 -0400
Received: from scooby.simplesystems.org (scooby.simplesystems.org
	[65.66.246.67])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k9PG06fP029268
	for <tiff@lists.maptools.org>; Wed, 25 Oct 2006 12:00:07 -0400
Received: from blade.simplesystems.org (blade.simplesystems.org [65.66.246.74])
	by scooby.simplesystems.org (8.12.10+Sun/8.12.10) with ESMTP id
	k9PG03w5023486; Wed, 25 Oct 2006 11:00:03 -0500 (CDT)
Date: Wed, 25 Oct 2006 11:00:03 -0500 (CDT)
From: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
X-X-Sender: bfriesen@blade.simplesystems.org
To: Amarnath S <amarnaths_vjt@yahoo.com>
Subject: Re: [Tiff] Newbie Question on Memory Usage within LibTiff
In-Reply-To: <200610250848.k9P8mePT023011@duke.maptools.org>
Message-ID: <Pine.SOC.4.60.0610251052150.889@blade.simplesystems.org>
References: <200610250848.k9P8mePT023011@duke.maptools.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc: tiff@lists.maptools.org
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>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00001c9c
X-MSP-STORE: Wed, 25 Oct 2006 18:15:37 +0200
Status:   

On Wed, 25 Oct 2006, Amarnath S wrote:

> 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.

Note that the term "leak" implies that if the same code path is 
executed again, additional memory (and probably of similar proportion) 
will be consumed.  It is not uncommon for libraries to create "static" 
allocations which are allocated only once in the lifetime of the 
program.  This also includes system libraries.  These would appear as 
"leaks" using your method, but are not actual leaks.  A better way to 
prove leaks is to execute the same path 1000 times and see if the 
memory use continues to grow.

The Windows memory allocator is weird in that it reclaims deallocated 
memory on an as-needed or as-convenient basis for use by other 
programs.  This differs from the traditional Unix approach where any 
memory allocated is retained for later use by the program.  However, 
many modern Unix systems use a malloc()/free() implementation which 
does return large allocations to the system by using using memory 
mapping to perform the allocation.

Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

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