- 双击安装"WinDbg_X86_v10.0.18362.1.msi",本机模块目录在:D:\Windows Kits\10\Debuggers,若找不到,则到看"开始菜单\Windows Kits"里有没有"WinDbg",若有则通过右击查看它的安装目录。
- 进入WinDbg安装目录,例如:D:\Windows Kits\10\Debuggers\x86,打开CMD窗口。
开始检测,执行命令:gflags.exe /i "MyApplication.exe" +ust
成功输出:
Current Registry Settings for MyApplication.exe executable are: 00001000
ust - Create user mode stack trace database
停止检测,执行命令:gflags.exe /i "MyApplication.exe" -ust
- 设置程序符号路径(程序PDB不设置,分析出的堆栈没有行号,路径尽量不要带空格和引号)
set _NT_SYMBOL_PATH=E:\workspace\MyApplication\Debug
- 利用UMDH创建Heap快照
执行命令:umdh.exe -pn:"MyApplication.exe" -f:"E:\snap1.log"
程序执行一段时间后或程序占用内存增加时,修改"snap1.log"为"snap2.log",再次创建Heap快照。 - 分析对比快照
执行命令:umdh.exe -d "E:\snap1.log" "E:\snap2.log" -f:"E:\result_1-2.txt"
或umdh.exe -d "E:\snap1.log" "E:\snap2.log" > "E:\result_1-2.txt"