login about faq

My program is a multithreaded 32-Bit MFC application compiled with VC10 in Unicode. It uses multiple DLLs (MFC and Win32) which internally also use some of the Chilkat libs. Some of the DLLs are loaded dynamically.

At shutdown memory leaks are reported. I want to avoid that because I need to find my own real memory leaks. I also read the support articles about that on the support pages.

Now my question:

Where in my program has CkSettings::initializeMultithreaded() to be called (in main of the exe AND/OR in each main of the DLLs) ?

Where in my program has CkSettings:: cleanupMemory() to be called (at end of the exe AND/OR at end of each DLL) ?

asked Apr 24 '13 at 09:29

chilkat's gravatar image

chilkat ♦♦

The CkSettings::initializeMultithreaded should only be called once from main at the start of your program prior to any other Chilkat calls, and prior to starting any other threads.

The CkSettings:: cleanupMemory() should be called only from main at the very end of your program, after all Chilkat objects have been destructed, and after all threads that might be using Chilkat objects have ended. Note: You would never want to declare a Chilkat object as a global static variable because it would be destructed after the call to cleanupMemory. Likewise, you would never declare a Chilkat object as a local var within main at the same level where cleanupMemory is called -- because it won't be destructed until after cleanupMemory is called. For example, the following code would be bad:

CkSsh myGlobalSsh;   // This is bad.

int main(int argc, char *argv[]) { CkZip zip; // This is also bad..

// Both Chilkat objects in this sample code are not destructed until AFTER cleanupMemory is called. // This should be avoided. CkSettings::cleanupMemory(); }


answered Apr 24 '13 at 09:36

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Apr 24 '13 at 09:29

Seen: 2,842 times

Last updated: Apr 24 '13 at 09:36

powered by OSQA