Skip to main content
GameDev.net gamedev.net
🔒 Locked

Tracking memory corruption

Started by Toolmaker Dec 23, 2004 at 6:33 AM 0 replies 250+ views
Original Post
Toolmaker
Toolmaker
I got a very strange problem with one of my applications. When a user disconnects from my server I want to save it's profile. I'm using a XML file to store the profile, and use PML as writer. PML is a XML style parser/writer. However, it crashes on the destructor of the main PML object. And specifically, it crashes on the call to free(). Ofcourse, when free() is crashing, it's for sure I corrupted the stack/heap somewhere. However, I have no idea how to track the corruption without removing all my code. The profile is stored in a safe pointer container(Which I wrote myself as a fun learning experience). But, it crashes somewhere along the lines. I can't remove any of this code, since they both need eachother. Is there a tool out there which allows me to track where I'm destroying my memory? I know there's some professional tool out there to track mem leaks, etc.(Can't remember the name), but I don't have the money to shell out 750 dollar for such a tool ;). If you want to take a look at the smartpointer, you can find it here: http://www.lepouya.com/upload/SmartPointer.h Toolmaker
 
gulgi
gulgi
The thing that I've done that works every time is to put in a few calls to _CrtCheckMemory().

The header you have to include is: crtdbg.h.
You might want to read up on this function as well: _CrtSetDbgFlag

All this is win32 specific though..
I have tracked memory corruption on consoles, but that required me to write my own memory handler, wich is a bit of a bigger job. :D

Good luck!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.