Use UMDH to identify memory leak problem
原文链接:https://www.thinksaas.cn/group/topic/634356/
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
- Download PDB file and copy to the “C:xosymbol” which is set part of above environment variable “_NT_SYMBOL_PATH”
Start collecting stack traces for user-mode allocations, run command:
gflags /i +ustRestart your process.
- Keep it running, wait until it become steady..
Collect a baseline snapshot, run command:
umdh -pn: -f:c:1.logWait until the memory usage of your process exceeds 1GB or more.
Generate a new snapshot, run command:
umdh -pn: -f:c:2.logCompare the two snapshots and get the final report from UMDH
umdh -d c:1.log c:2.log > c:
esult12.logIn 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/
本文介绍如何利用UMDH工具来诊断和定位Windows应用程序中的内存泄漏问题。通过安装WinDbg并设置相应的环境变量,可以收集内存分配的堆栈跟踪,并生成基线快照进行对比分析,最终找到导致内存泄漏的具体位置。

5993

被折叠的 条评论
为什么被折叠?



