Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,
I need a help with memory leak detection in my DLL which is loaded into third party application as extension. It is similar as extension in SQLite, but not the same. There are registered some functions which are then called by entry point.

Such as:
C++
int cmd_print(const char* unparsed)
{
  printf("PRINT: %s", unparsed);
  return 0;
}


What I need is to catch leaks in similar method, something like:

C++
int cmd_execute(const char* unparsed)
{
  InitLeakDetection(); // this could be a library method to start leak detection
  
  int status = DoExecuteStuff(unparsed);

  DumpMemoryLeaks();   // this could be a library method to end leak detection

  return status;
}


I have tried:
StackWalker - works, but I do not know how to localize leak by its ordinal, because
it is after each function call a greater number.
Visual Leak Detector - locks main thread and I can not resolve it
CRT functions - requires 'new' oerator overload, which makes problems to compile with BOOST libraries

Could you please help me? How would you do it?

IDE: VS2005
Language: C++
Third party app: Bentley MicroStation

Thanks
Posted
Updated 1-Oct-13 19:38pm
v3
Comments
chandanadhikari 1-Oct-13 7:53am    
hi,
what i understand from your question is you are trying to put the leak checking in the code itself. I am not sure if that is the best way out and I have never done that. Rather use Application Verifier and Debug Diag tools to catch the leaks by running the process in whose memory space the dll gets loaded and then analyse the call stack or do post mortem analysis .
may i know why do you want to put leak check in code ?
Sergey Alexandrovich Kryukov 1-Oct-13 18:50pm    
This is actually a very good approach.
—SA
Dusan Paulovic 2-Oct-13 1:41am    
I did not want to do it this way, but seems that I would have to. That way, of corse, I would perhaps see all memory issues and events of process...
Sergey Alexandrovich Kryukov 1-Oct-13 13:11pm    
I could understand "extension DLL", but what is "DLL extension"?
—SA
Dusan Paulovic 2-Oct-13 1:39am    
Thanks, I have it corrected :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900