DebugDiagx检测内存泄露

 

1. 安装DebugDiagx63.exe

2. 运行需要测试的程序UnitTest.exe.

3. 打开DebugDiag1.2, 选择 ”Native (non-.Net) Memory and Handle Leak” ,然后next.

4. 选中UnitTest.exe进程, next

5. 保持default选择, next

6. 生成Leak Rules, 保持default选择, next

7. 保持”Active the rule now”选择, Finish.

8. ToolsàOptions And Settings

(1) Folders and Search Paths: 添加Symbols文件: SRV*D:\symbol*http://msdl.microsoft.com/download/symbols;D:\xxx-YourProjectPdbFilePath.

Dump文件保存路径保持不变.

 

(2) Preferences: 勾选”检测内存泄露时立即记录调用栈信息”,当测试时间>15mins时不建议勾选.

  

9. 运行UnitTest程序,为了产生较多的泄露,可以多运行几次.

10. Rules选项卡中,右键点击Leak RuleàDump Target Process(es)àCreate Full Userdump(s).从而生成dump文件.位置在E:\Program Files\DebugDiag\Logs\Misc下.

 

 11. Advanced Analysis选项卡, 选中第二个”Memory Pressure Analyzers” (第一个是分析托管的内存). 然后点击Add Data Files. 加载Misc文件夹下的dump文件, 然后点击”Start Analysis”按钮进行分析, 会生成一个html页面, 在IE中自动打开.

 

12. 在页面中搜索,找到 ”Module details for mfc100”, 查询其 ”operator new”函数的调用栈samples. 可以找到代码中用到new可能造成的内存泄露之处.

Function

Source

Destination

mfc100!operator new+33

 

 

TestCaseAdapter!CTracerouteAdapterFactory::CreateObject+2d

d:\xxx\tracerouteadapter.cpp @ 39 + 8

mfc100!operator new

TestCases!TracerouteTest::testTracerouteWithWrongHost+153

d:\xxx\traceroutetest.cpp @ 67 + 16

 

posted @ 2013-01-11 10:54  金石开  阅读(4310)  评论(0编辑  收藏  举报