Jump to content
  • Advertisement
Sign in to follow this  
silvia_steven_2000

Free Simple C++ Memory Debugging Tools

This topic is 4981 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Oh shoot, sorry good catch. I missed typed. I meant when you try to dereference it:)

Thanks Martee, my face is red
Cheers
Chris

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!