Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
RSA
S/MIME
Socket
Spider
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
FileAccess
Bzip2
LZW
Icon

 

 

 

 

 

 

 

 

Chilkat C++ Libs have Memory Leaks?

Download Chilkat C/C++ Libraries for VC++ 9.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C/C++ 64-bit Libraries for VC++ 8.0 / x64

Download Chilkat Visual Studio 2005 C/C++ Libs for Windows Mobile, Pocket PC, SmartPhone, WinCE

Download Chilkat C/C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0, Win 95/98/NT4 Compatible

This example discusses the often-mistaken case of memory leaks in the Chilkat C++ libraries.

#define _CRTDBG_MAP_ALLOC
#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;
    xml.LoadXmlFile("crisp.xml");
    xml.SaveXml("out.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)
{
    TestLoadXml();

    // 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.
    CkSettings::cleanupMemory();

    _CrtDumpMemoryLeaks();

    return 0;
}


 

 

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Mail Component · XML Parser