memory leak dump reporting wrong file, line number

B

Bill Rogers

I have been trying to get _CrtDumpMemoryLeaks() to report the allocation
point file and line number in my source file. Instead it always reports the
allocation occurred in crtdbg.h, line 692. I would like it to report my
source file name and line number. What am I missing?
Thanks,
Bill Rogers

Test program code:

// LeakTest.cpp : Defines the entry point for the console application.

#define _CRTDBG_MAP_ALLOC

#include <stdlib.h>

#include <crtdbg.h>

#include <tchar.h>

int _tmain(int argc, _TCHAR* argv[])

{

char *s = new char[100];

_CrtDumpMemoryLeaks();

return 0;

}



This produces the following output in the output window:

Detected memory leaks!

Dumping objects ->

c:\program files\microsoft visual studio .net 2003\vc7\include\crtdbg.h(692)
: {43} normal block at 0x00320FF0, 100 bytes long.

Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD

Object dump complete.

The program '[1932] LeakTest.exe: Native' has exited with code 0 (0x0).
 
J

Jochen Kalmbach

Bill said:
I have been trying to get _CrtDumpMemoryLeaks() to report the
allocation point file and line number in my source file. Instead it
always reports the allocation occurred in crtdbg.h, line 692. I would
like it to report my source file name and line number.

This will become more stupid if you are using STL.... The build-in
mechanism is very simple...

If you want a detailed info with the callsatck (so you can see what really
happens), then use the Memory-Leak-Finder:

http://www.codeproject.com/useritems/leakfinder.asp

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/useritems/leakfinder.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top