Tracing memory-leaks* under Windows

Written by  on March 2, 2018 

For a long time I am searching for a useable profiler for windows,
which does not only track the time (like VerySleepy) but memory-usage.
I was used to Instruments under OSX and – boy – I was surprised there
is nothing comparable under Windows.
Visual Studio newer than 2013 is not useable – I know there are profilers integrated.
Dr. Memory crashes at start.
AppVerifier does not work (crash).
http://wiki.qt.io/Profiling_and_Memory_Checking_Tools has some more
hints, but let me present the two tools which finally gave me some
insight:


MTuner (https://github.com/milostosic/MTuner) from Milos Tosic (2017)


Pro: works out of the box without any reconfiguration of the app;
captures data which can be evaluated later; fancy looking; actively
maintained at github (answers error-reports fast); does not need much
explanation
Con: crashes currently while evaluating the bigger traces (400 MiByte+)


And then one Microsoft tool: UMDH

Con: much trouble to acquire and getting it to work (long explanation)
Pro: but the diff of the allocations as stacktraces can be helpful

0. install windows SDK
1. set the gflags correctly: means allow stacktraces for the process
2. capture two snapshots of current image of the process
C:\Program Files (x86)\Windows Kits\10\Debuggers\x86>umdh.exe -p:8480
-f:c:\alloc0.txt
and some moments/actions later
C:\Program Files (x86)\Windows Kits\10\Debuggers\x86>umdh.exe -p:8480
-f:c:\alloc1.txt
3. compare and get starting line 300-400 some descending view of the
biggest allocation-changes:
C:\Program Files (x86)\Windows Kits\10\Debuggers\x86>umdh.exe -d
c:\alloc0.txt c:\alloc1.txt > c:\alloc_diff10o1.txt

at *: I know, sometimes it is not a leak, but “by design” 😉

Category : C++VisualStudioWin

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.