The debug C run-time library with Visual Studio can track all allocations and automatically report any that aren't freed at application exit. First, include <crtdbg.h>
, and then at the very beginning of your program, ask it to track allocation and report leaks by making this call:
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
In the debug output window of the Visual Studio debugger (or another program that monitors the debug output), you'll see a report of leaked allocations when the application ends.
In general, you probably only want to do this in a debug build, as there is a nontrivial performance impact.
Also note that if you allocate singletons and never free them, they will (not surprisingly) be reported as leaks.
Full details are in MSDN.