I've been trying to debug a subtle memory problem in a large project. It's been weeks and I still haven't been able to find it. My program crashes randomly after running for a certain amount of time. As a result, I've been trying to obtain a memory debugger of sorts. Here are the options I have considered/tried:
- IBM Purify - successfully detects memory leak but asks for me to pay money to find out where it is
- Valgrind - I've heard good things about this program but it's for Linux and I'd have to port my entire project over
- MPatrol - again it's mainly for linux. The windows version is for MingGW and I'm using Visual Studio. I found binaries for VC++ online and followed the instructions there but the program refused to output any log files.
- Application Verifier - throws a random break point at start, asks for a nonexistent source file (sdk.cpp) in Visual Studio, and then gives this error every time, no matter what exe I attach it to: "First chance access violation for current stack trace"
- WinDbg - I don't even know if this program does what I think it does. Always gives "ERROR: Symbol file could not be found." And it doesn't seem to do anything when I run my exe.
I've searched for all these errors on Google for hours to no avail. The respective documentation on these packages don't seem to have info on my particular issues. Is there any debugger out there that works? Do I really have to port my program over to Linux? Can anyone point me in the direction of good documentation regarding memory debugging? Any help would be greatly appreciated. Thanks in advance!
Edit:
Thanks for all the replies. I realize that the crashing problem is probably not a memory leak. After running for a while, it just freezes. There's no error message. Usually it happens while writing to cout. So thus I figured it was memory corruption of some sort. I guess I'll look into more in-depth features of visual studio. Actually using the trial of Purify I found a few bugs but I don't want to cough up $1600 for the full version. Worst case scenario I'll port it to Linux. Thanks again for the help.
Edit 2:
After some more testing with Purify, it appears that my program doesn't have any more memory errors. I noticed that the program freezes when I click on it, as in the command prompt itself. Thus I'm going to assume that it's not a problem with my code, but rather the way it interacts with having text selected. (Edit 2a: selection is supposed to do that facepalm) Thanks again for all the help.
For future reference, where do I go to learn about more sophisticated debugging? I've used breakpoints and watch expressions but at school they only teach the language itself. Do I need to learn x86 assembly?