Windows堆内存泄露

Windows下一般使用gflags + umdh分析堆内存泄露

设置gflags.exe

以管理员权限运行cmd
(1) 设置symbol 环境变量
set _NT_SYMBOL_PATH=srv*D:\Symbol*http://msdl.microsoft.com/download/symbols;C:\Users\John\Desktop\Creator Magic\VirtualPrinter\TempFiles
(2) 运行gflags.exe
gflags.exe /i splwow64.exe +ust
(3) 发现内存泄露,用umdh第一次做快照
umdh.exe -pn:splwow64.exe -f:snap1.log
(4) 程序运行一段时间,第二次做快照
umdh.exe -pn:splwow64.exe -f:snap2.log
(5) 生成差异文件
umdh.exe -d snap1.log snap2.log -f:result.txt
(6) 查看差异文件("C:\Program Files\Windows Kits\10\Debuggers\x64" 下)
发现增加了26个0x58=2288/26大小的内存块, 很可能这里产生泄露
//                                                                          
// Each log entry has the following syntax:                                 
//                                                                          
// + BYTES_DELTA (NEW_BYTES - OLD_BYTES) NEW_COUNT allocs BackTrace TRACEID 
// + COUNT_DELTA (NEW_COUNT - OLD_COUNT) BackTrace TRACEID allocations      
//     ... stack trace ...                                                  
//                                                                          
// where:                                                                   
//                                                                          
//     BYTES_DELTA - increase in bytes between before and after log         
//     NEW_BYTES - bytes in after log                                       
//     OLD_BYTES - bytes in before log                                      
//     COUNT_DELTA - increase in allocations between before and after log   
//     NEW_COUNT - number of allocations in after log                       
//     OLD_COUNT - number of allocations in before log                      
//     TRACEID - decimal index of the stack trace in the trace database     
//         (can be used to search for allocation instances in the original  
//         UMDH logs).                                                      
// 

为了进一步确认,用procexp64抓dump分析

(1) !heap –s  查看当前进程所有堆的摘要信息

(2) !heap -l 检测 leaked heap blocks

(3) !heap -stat -h 查看堆的使用情况统计

(4) !heap -flt s 查看指定大小的heap allocations

(5) !heap -p -a 查看指点UserPtr对应的调用栈

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值