For C/C++ projects in Linux, the reference tools to spot memory corruption and memleaks if of course Valgrind. But I'm currently coding on Windows during my internship, and despite that fact that I like valgrind very much, my hate for the command line in Windows is much greater.
I gave a try to drmemory and fell in love immediately:
- Free software
- Integration with Visual Studio
- Quicker than valgrind
- Dead simple to install
The process is pretty straightforward: Get it, install it, and set the following flags in VS to get nice backtraces:
- /Zi enables debug data
- /Ob0 disables inlining
- /Oy- disables frame pointer optimization
- /DEBUG tells the linker to be nice
Go to "Tools", "External Tools", "Add", and fill the fields:
Title: Dr. Memory Command: C:\Program Files (x86)\Dr. Memory\bin\drmemory.exe Arguments: -visual_studio -- $(TargetPath) Initial Directory: $(TargetDir)
And that's it, you can now click on the "Dr. Memory" item in your Tools menu to launch your binary within drmemory.