Free Simple C++ Memory Debugging Tools
Hi All
I am having some memory allocation and deallocation problem.
its seems I am trying to delete an already deleted pointer.
I searched the code and could not figure out what is going on.
is there some free and simple tool that would help in figuring out what is going on with my program. I googled the web and there is allot about memory tools. some is commercial and some is free but huge and difficult to integrate in VC++. is there some light tool that can be easily integrated to a VC++ project and trace memory operations.
thanks for help, appreciate your time.
The vs.net runtime has some great crt debugging api's do an msdn search for CrtDumpMemoryLeaks.
Cheers
Chris
Cheers
Chris
Quote:Original post by chollida1
The vs.net runtime has some great crt debugging api's do an msdn search for CrtDumpMemoryLeaks.
Cheers
Chris
I agree, and it's also quite easy to use.
More competent, but also much harder to use is UMDH. It's a free tool from Microsoft that makes use of OS functionality for heap tracking.
http://weblogs.asp.net/mdavey/archive/2004/03/09/86569.aspx
http://msdn.microsoft.com/isapi/gosupport.asp?TARGET=/?kbid=268343
Related to this I'd suggest looking at PageHeap. It's another free tool from Microsoft, used to find invalid access to memory (double free, out-of-bound access to allocated memory etc.)
Also worth looking at is oh.exe, which is used to track handle leaks (events, sockets, mutexes, sockets etc.). http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/oh-o.asp
I am gonna try it but it says it is used to detect memory leaks. I think my problem is that I am attempting to deallocate an already freed memory. does this tool (and the msdn method) detect that ?
Try to get in the habit of setting free'd/deleted memory to null when your done. This way you'll get an exception/crash due to a null pointer dereference when you try to delete it a second time.
THis makes it dirt simple to find double free/deletes.
Cheers
Chris
THis makes it dirt simple to find double free/deletes.
Cheers
Chris
You'll get an exception when you try to dereference your null pointer, not when you try to delete it a second time. Calling delete or free() on a null pointer has no effect.
Oh shoot, sorry good catch. I missed typed. I meant when you try to dereference it:)
Thanks Martee, my face is red
Cheers
Chris
Thanks Martee, my face is red
Cheers
Chris
Quote:Original post by silvia_steven_2000
I am gonna try it but it says it is used to detect memory leaks. I think my problem is that I am attempting to deallocate an already freed memory. does this tool (and the msdn method) detect that ?
Yes, the CRT memory debugging stuff can help detect double-deletion if you set the right flags. Look for _CrtSetDbgFlag() in the MSDN documentation. If you set checks to maximum things will run kind of slowly but you should catch your bug pretty easily.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement