Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

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


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

 

Testing for Memory Leaks in the Zip Library

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

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

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

Discusses the often-mistaken case of memory leaks in the Chilkat C++ library.

// The Chilkat C++ library creates some "stay-resident"
// structures on an as-needed basis that are not deallocated.  
// (They are deallocated from within CkSettings::cleanupMemory which can be
// called once at the end of your program.) 
// The stay-resident structures exist for performance reasons.  
// As an example, the CkZip class will initialize and
// keep huffman encoding tables in memory the first time it is called. 
 
// To check for memory leaks, make sure all Chilkat objects have been destructed
// and *then* call CkSettings::cleanupMemory.  One caveat: once CkSettings::cleanupMemory
// has been called, the program should *not* create any more Chilkat objects.
// Also, if you want to check for memory leaks, do not declare any Chilkat objects
// as global variables.  Global variables are destructed *after* the program's mainline
// has exited, so there is no way to call CkSettings::cleanupMemory after all Chilkat objects
// have been destructed.
void TestZip(void)
    {
    // Open a Zip and unzip it to the testDir subdirectory.
    CkZip zip;
    zip.UnlockComponent("Anything for 30-day trial");
    zip.OpenZip("test.zip");
    zip.Unzip("./testDir",0);
    zip.CloseZip();
    }

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
    // When TestZip returns, the Chilkat object(s) have been destructed, so we can
    // now call cleanupMemory.   
    TestZip();

    CkSettings::cleanupMemory();

    // At this point in the code, there should be no memory leaks...

    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