Detect Memory Leaks in my DLL code?

I have a C++ dll used for a JNI Java project.
I added:

1
2
3
4
5
6
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>

// This at end of dll execution (in the destructor of main class)
_CrtDumpMemoryLeaks();


Before _CrtDumpMemoryLeaks(); is called I purposely create memory leaks:

1
2
3
4
5
6
7
char *string;
string = new char[20];

for (int i = 0; i != 5; ++i) {
  new OCRManager();
  std::cout << "Leak Created" << std::endl;
}


I run my Java app that makes native calls to the DLL and when it finished executing I do not get the leak report.

Am I missing something? Can I even get the report when calling the dll from Java?

Is there another way to run the dll so I can see the leaks?

I am using VS 2008 under Windows XP

Thanks for any help!
Is it a release or debug build?
Debug.
I would expect _CrtDumpMemoryLeaks() to report a leak. In fact, I just tested it with a C++ DLL and app on VS2005.
Topic archived. No new replies allowed.