Artificial truth

The more you see, the less you believe.

[archives] [latest] | [homepage] | [atom/rss]

Memory debugging under Windows with drmemory
Mon 06 January 2014 — download

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

Installation

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

Integration with Visual Studio

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)

Enjoy

And that's it, you can now click on the "Dr. Memory" item in your Tools menu to launch your binary within drmemory.