Original Post
I've found a memory leak in my current project, and although it's easy enough for me to repeat it and find the user input that causes it, I can't seem to track down where in code it occurs. I'm currently using VC++ 6.0 with
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF|_CRTDBG_ALLOC_MEM_DF);
_CrtSetReportMode(_CRT_ASSERT,_CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT,_CRTDBG_FILE_STDERR);
to print out any memory leaks it finds, and although it shows its output fine:
Detected memory leaks!
Dumping objects ->
{4423} normal block at 0x004544F0, 5 bytes long.
Data: <room > 72 6F 6F 6D 00
{4422} normal block at 0x00454670, 5 bytes long.
Data: <room > 72 6F 6F 6D 00
{4421} normal block at 0x004546B0, 5 bytes long.
Data: <room > 72 6F 6F 6D 00
{4420} normal block at 0x00454770, 5 bytes long.
Data: <room > 72 6F 6F 6D 00
Object dump complete.
I can't seem to find where the memory is allocated to begin with, much less why it is never deallocated. Unfortunately the data, "room " doesn't help very much in this particular situation. However, I have noticed that the address of the leaked data is pretty consistent. This has made me wonder if there's a way I can set a debugger to break when a certain memory location is accessed, so I can at least know where the memory is allocated, and then figure out where it should be deallocated and why it isn't. I've been searching for a rather while and will continue to do so, but I've been wondering if there is an easier way to go about hunting down this memory leak.
Thanks in advance for any advice you may have!
-Arek the Absolute
[edited by - Arek the Absolute on March 11, 2004 12:31:29 AM]