<p>I've got a Win32 C++ app with a suite of unit tests.  After the unit tests have finished running, I'd like a human-readable report on any unfreed memory to be automatically generated.  Ideally, the report will have a stack with files &amp; line number info for each unfreed allocation.  It would be nice to have them generated in a consistent order to make it easy to diff it from one run to the next.  (Basically, I would like the results of valgrind --leak-check=full, but on windows).  </p>

<p>I've had success with UMDH getting this kind of info from running processes, but that tool only seems to work if you attach to an existing process.  I want this to happen automatically every time I run my unit tests.</p>

<p>Is there a tool that can do this?  If so, how do I use it?  </p>

<p>Thanks!</p>

If you're using MSVC, Microsoft's Debug heap functions can be used to generate the report you want, but it may not be as automatic as you'd like (you may need to write some custom code):
```
```
_CrtSetReportMode
_CrtSetReportFile
_CrtMemState    
_CrtMemCheckpoint
_CrtMemDumpStatistics
_CrtSetReportFile
_CrtSetDbgFlag
```
```