Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component

Index of Chilkat Blog Posts

September 7, 2006

C++ Memory Leaks?

Question: Does the Chilkat C++ library have memory leaks?

Answer: No, this example program explains the issue:

#include "stdafx.h"
#include <stdio .h>
#include <crtdbg .h>
#include "C:/ck2000/components/ChilkatLib/Package/include/CkSettings.h"
#include "C:/ck2000/components/ChilkatLib/Package/include/CkXml.h"
void TestLoadXml(void)
    CkXml xml;
// Many C++ developers incorrectly think there are memory leaks
// in the Chilkat C++ libraries.  This is not the case.
// For performance reasons Chilkat C++ classes *may* utilize internal
// structures in memory that are built/initialized once and re-used
// during subsequent method calls.  Calling CkSettings::cleanupMemory
// deallocates these structures.  However, once cleanupMemory is called,
// no other Chilkat methods can be called, including object destructors.
// The cleanupMemory method is provided for those programmers that wish
// to check for memory leaks.
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
    // Only necessary if checking for memory leaks.
    // Only call just before exiting the program.
    // In this example you will notice that if cleanupMemory
    // is commented out, it will appear as if there are memory leaks.
    // If you call cleanupMemory, you will see that there are no leaks.
    // In fact, if you write a "for" loop an call TestLoadXml 100,000 times,
    // you will see that memory usage does not steadily increase.  This is
    // because the internal structures that may be created are created once
    // and re-used.
    return 0;

Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.