TIFF and LibTiff Mail List Archive


2004.10.21 14:52 "[Tiff] Memory Leak?", by Harith Frangoul
2004.11.12 19:03 "Re: [Tiff] Memory Leak?", by Andrey Kiselev

2004.10.21 14:52 "[Tiff] Memory Leak?", by Harith Frangoul


I'm using tifflib version 3.1.6.

There is an apparent memory leak in the library.

I wrote a simple program to open and close a tiff file in a loop and watched
the memory increase gradually.

Here is the program written as a console app in VS C++ 6.0.

// TiffTest.cpp: Defines the entry point for the console application.


#include "stdafx.h"

#include "TiffTest.h"

#include "tiffio.h"

#include "direct.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;



// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])


// initialize MFC and print and error on failure

if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))


                        // TODO: change error code to suit your needs

                        cerr << _T("Fatal Error: MFC initialization failed")
<< endl;

                        return 1;


            char exeFilePath[MAX_PATH];

            char drive[_MAX_DRIVE];

            char dir[_MAX_DIR];

            char fname[_MAX_FNAME];

            char ext[_MAX_EXT];

            CString strFilePath;

            // get the exe file name

GetModuleFileName(0, exeFilePath, MAX_PATH);

            _splitpath(exeFilePath, drive, dir, fname, ext);

strFilePath.Format("%s%s%s", drive, dir, "FILES");


            strFilePath += "\\CHECK.TIF";

            TIFF *image;

            for (int i = 1; i < 100000; i++) {

                        //Open the TIFF Image

                        if((image = TIFFOpen(strFilePath, "rM")) == NULL) {

                                    printf("Error in opening TIFF\n");




                        image = NULL;


            return 0;