3

Can anyone recommend a quality C++ memory debugging API or software for Windows(specifically, one that works with MinGW)? I'm nearly positive there's a memory leak in my program, but I have no idea where to start looking.

Also, on a related note, I previously tried overloading the global new and delete operators myself, and storing debugging information from there. Yet, when I try to replace every occurrence of new with my overloaded operator, it throws a bunch of errors. I only tried using a simple preprocessor macro to do so.

#define new new(__FILE__, __LINE__)

Is there any distinct way around that problem?

EDIT: I probably should have been clearer with this. I did in fact declare an overload, and implemented it without any errors. The only problem was when I tried using a macro to replace all uses of the new operator to use my overload instead, which is why I only posted the macro code.

B3tturTh3nU
  • 163
  • 4
  • 12
  • 1
    Of course your macro throws errors. There is no overload of [operator new](http://www.cplusplus.com/reference/std/new/operator%20new/) that takes those arguments. Defining a macro doesn't just create an applicable function for you. – Ed S. Jun 12 '11 at 01:20
  • I don't want to sound condescending but the macro opens the way for a silly error: is your `new` defined *before* the macro appears? Why not ignore that altogether and define the global `new` (the one without arguments), doing the logging and getting the memory from e.g. `operator new`? – Luc Danton Jun 12 '11 at 01:21
  • @Luc, nope. I made sure to add the declaration of my overload before the macro. Although, I may try just overloading the regular global. – B3tturTh3nU Jun 12 '11 at 01:28

1 Answers1

3

For memory leaks in Windows, I've found that UMDH with usermode stack traces enabled is pretty useful. Here's a tutorial.

For a list of other tools, look here.

Community
  • 1
  • 1
pepsi
  • 6,785
  • 6
  • 42
  • 74
  • This seems to be what I'm looking for, thanks. Hopefully it will help me uncover where the leak is coming from. – B3tturTh3nU Jun 12 '11 at 01:50