Use UMDH to identify memory leak problem

We sometimes got memory leak problem, and we need to find the leaked memory, Here is a usful tool from MS, UMDH, it is included in WinDBG install package.

  • It need the PDB files to analyse access the symbol table, then a human readable stack can be generated.
  • You need to generated two set of current used memory, and compare the two to have a result.
  • It compares the current used memory, so you can identify the still-in-use memory, That is the memory you stored somewhere, but they will actually never be used again, and should be released.
  • And of cause, it can identify the memory with out a ptr pointing to when comparing.

You should let memory leak a little more to get a clear view of the result.

Here is the steps to use UMDH:
1. Install Windbg, you can get WinDBG from MS site:http://msdn.microsoft.com/en-us/windows/hardware/hh852365
2. Open a Dos Prompt as Administrator and navigate to the installation folder of WinDbg
3. Set Symbol Path as a System Variable

set _NT_SYMBOL_PATH= SRV*C:\websymbols*http://msdl.microsoft.com/download/symbols; c:\xosymbol

4. Download PDB file and copy to the “C:\xosymbol” which is set part of above environment variable “_NT_SYMBOL_PATH”
5. Start collecting stack traces for user-mode allocations, run command:
gflags /i <Your_process_name.exe> +ust

6. Restart your process.
7. Keep it running, wait until it become steady..
8. Collect a baseline snapshot, run command:
umdh -pn:<Your_process_name.exe> -f:c:\1.log

9. Wait until the memory usage of your process exceeds 1GB or more.
10. Generate a new snapshot, run command:
umdh -pn:<Your_process_name.exe> -f:c:\2.log

11. Compare the two snapshots and get the final report from UMDH
umdh -d c:\1.log c:\2.log > c:\result12.log

12. In the result, we can see the stack where the leaked memory is allocated, You got a direct hint to resolve the leak problem.



And if you need an example, please go to page https://www.hyzblog.com/use-umdh-identify-memory-leak-problem/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值