Topic
  • 1 reply
  • Latest Post - ‏2014-11-05T20:37:40Z by Kenneth_IL
Kenneth_IL
Kenneth_IL
21 Posts

Pinned topic C++ API - Memory Leak

‏2013-05-03T18:51:40Z |

I have and odd problem.  I developing an application using MS VC++ 2008 utilizing the >NET Frame Work.  When I simply include DKDatastoreICM.hpp I get  a  DKNotExistException at program startup.   I have not defined any variables of the types in the CM API I just have the include statement for the header file.  When the program terminates the CRT display the bunch of memory leaks that have occured even though I haven't allocated any CM API objects.  When I command out the include DKDatastoreICM.hpp the exception goes away as well as the memory leaks.  It seems as though some start up code in a dll is allocating something when it is loaded.

  • Kenneth_IL
    Kenneth_IL
    21 Posts
    ACCEPTED ANSWER

    Re: C++ API - Memory Leak

    ‏2014-11-05T20:37:40Z  

    This is an old thread but I solved the problem so I'll just pass on what I learned to help others.  The problem was that the DLL was built with one version of the VC RTL and my app was compiled with another.  When a new object is instantiated in my the rtl used to compile my app calls malloc.  When the object is delete the destroy the object it calls free using the RTL that the DLL was compiled against.  So the DLL is calling free on a memory block that was allocated with a different version of the RTL.  I changed the RTL I was  using to match the one the DLL was linked to and the problem was solved.

  • Kenneth_IL
    Kenneth_IL
    21 Posts

    Re: C++ API - Memory Leak

    ‏2014-11-05T20:37:40Z  

    This is an old thread but I solved the problem so I'll just pass on what I learned to help others.  The problem was that the DLL was built with one version of the VC RTL and my app was compiled with another.  When a new object is instantiated in my the rtl used to compile my app calls malloc.  When the object is delete the destroy the object it calls free using the RTL that the DLL was compiled against.  So the DLL is calling free on a memory block that was allocated with a different version of the RTL.  I changed the RTL I was  using to match the one the DLL was linked to and the problem was solved.