如何用windbg分析内存泄露
1. 必须在命令行中设置为要分析的进程打开用户堆栈信息:C:\Program Files\Debugging Tools for Windows (x64)>gflags.exe -i YourDebugProcess.exe +ust
2. 必须是Debug版本的进程
3. 设置好windbg的pdb路径,即symbol path
4. 利用windbg的AttachToProcess (貌似后面这个方案不行:在目标机器上产生转储文件(dump)然后用windbg分析)。
5. 利用!heap命令
NtGlobalFlag enables following debugging aids for new heaps:
stack back traces
LFH Key : 0x00000052389f3a7e
Termination on corruption : ENABLED
Heap Flags Reserv Commit Virt Free List UCR Virt Lock Fast
(k) (k) (k) (k) length blocks cont. heap
-------------------------------------------------------------------------------------
0000000001b40000 08000002 1024 828 1024 19 20 1 0 0 LFH
0000000000010000 08008000 64 8 64 5 1 1 0 0
0000000000020000 08008000 64 64 64 61 1 1 0 0
0000000001d30000 08001002 1088 308 1088 18 2 2 0 0 LFH
00000000036b0000 08001002 512 288 512 7 9 1 0 0 LFH
0000000001c60000 08001002 355456 338872 355456 7750 140 26 0 0 LFH
0000000003e40000 08001002 512 260 512 7 2 1 0 0 LFH
0000000003f80000 08001002 64 8 64 3 1 1 0 0
0000000004040000 08001002 64 8 64 3 1 1 0 0
00000000048c0000 08011002 512 8 512 3 2 1 0 0
00000000049e0000 08001002 512 8 512 3 2 1 0 0
0000000004850000 08001002 3136 2192 3136 403 6 3 0 0 LFH
External fragmentation 18 % (6 free blocks)
0000000006d30000 08001002 1088 288 1088 5 2 2 0 0 LFH
00000000049a0000 08001002 1088 544 1088 265 4 2 0 0 LFH
00000000048a0000 08001002 1088 288 1088 9 3 2 0 0 LFH
00000000079d0000 08001002 1088 288 1088 9 3 2 0 0 LFH
0000000007b30000 08001002 1088 288 1088 9 3 2 0 0 LFH
0000000004c10000 08001002 1088 288 1088 9 3 2 0 0 LFH
0000000008820000 08001002 1088 288 1088 9 3 2 0 0 LFH
0000000008d80000 08001002 1088 288 1088 13 3 2 0 0 LFH
0000000004c00000 08001002 1088 288 1088 9 3 2 0 0 LFH
0000000006ce0000 08001002 1088 288 1088 9 3 2 0 0 LFH
0000000004940000 08001002 1088 288 1088 9 3 2 0 0 LFH
000000000a510000 08001002 1088 288 1088 9 3 2 0 0 LFH
000000000a780000 08001002 1088 292 1088 12 4 2 0 0 LFH
0000000008d70000 08001002 1088 256 1088 8 3 2 0 0 LFH
000000000b1a0000 08001002 512 8 512 2 1 1 0 0
-------------------------------------------------------------------------------------
0:032> !heap -stat -h 0000000001c60000
heap @ 0000000001c60000
group-by: TOTSIZE max-display: 20
size #blocks total ( %) (percent of total busy bytes)
261 - 13087bb4 (96.84)
8c 3579 - 1d3e2c (0.58)
44 4a8a - 13cca8 (0.39)
5c 35c9 - 13543c (0.38)
12c d0b - f48e4 (0.30)
54 2a65 - de924 (0.28)
4c 2c7f - d35b4 (0.26)
6c e53 - 60b04 (0.12)
1825c 3 - 48714 (0.09)
8034 8 - 401a0 (0.08)
2003e 2 - 4007c (0.08)
834 64 - 33450 (0.06)
64 815 - 32834 (0.06)
74 5a0 - 28c80 (0.05)
4034 9 - 241d4 (0.04)
84 273 - 1434c (0.03)
402c 4 - 100b0 (0.02)
10034 1 - 10034 (0.02)
1035 f - f31b (0.02)
94 185 - e0e4 (0.02)
0:032> !heap -flt s 80034
_HEAP @ 1b40000
_HEAP @ 10000
_HEAP @ 20000
_HEAP @ 1d30000
_HEAP @ 36b0000
_HEAP @ 1c60000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
00000000102e5a40 8006 0000 [00] 00000000102e5a70 80034 - (busy)
0000000010365aa0 8006 8006 [00] 0000000010365ad0 80034 - (busy)
0000000010402210 8006 8006 [00] 0000000010402240 80034 - (busy)
0000000010482270 8006 8006 [00] 00000000104822a0 80034 - (busy)
00000000105022d0 8006 8006 [00] 0000000010502300 80034 - (busy)
00000000105e9630 8006 8006 [00] 00000000105e9660 80034 - (busy)
...............
00000000250b0730 8006 8006 [00] 00000000250b0760 80034 - (busy)
0000000025130790 8006 8006 [00] 00000000251307c0 80034 - (busy)
00000000251b07f0 8006 8006 [00] 00000000251b0820 80034 - (busy)
0000000025230850 8006 8006 [00] 0000000025230880 80034 - (busy)
00000000252b08b0 8006 8006 [00] 00000000252b08e0 80034 - (busy)
0000000025330910 8006 8006 [00] 0000000025330940 80034 - (busy)
00000000253b0970 8006 8006 [00] 00000000253b09a0 80034 - (busy)
00000000254309d0 8006 8006 [00] 0000000025430a00 80034 - (busy)
00000000254b0a30 8006 8006 [00] 00000000254b0a60 80034 - (busy)
0000000025530a90 8006 8006 [00] 0000000025530ac0 80034 - (busy)
00000000255b0af0 8006 8006 [00] 00000000255b0b20 80034 - (busy)
0000000025630b50 8006 8006 [00] 0000000025630b80 80034 - (busy)
00000000256b0bb0 8006 8006 [00] 00000000256b0be0 80034 - (busy)
0000000025780070 8006 8006 [00] 00000000257800a0 80034 - (busy)
00000000258000d0 8006 8006 [00] 0000000025800100 80034 - (busy)
_HEAP @ 3e40000
_HEAP @ 3f80000
_HEAP @ 4040000
_HEAP @ 48c0000
_HEAP @ 49e0000
_HEAP @ 4850000
_HEAP @ 6d30000
_HEAP @ 49a0000
_HEAP @ 48a0000
_HEAP @ 79d0000
_HEAP @ 7b30000
_HEAP @ 4c10000
_HEAP @ 8820000
_HEAP @ 8d80000
_HEAP @ 4c00000
_HEAP @ 6ce0000
_HEAP @ 4940000
_HEAP @ a510000
_HEAP @ a780000
_HEAP @ 8d70000
_HEAP @ b1a0000
0:032> !heap -p -a 0000000025030700
address 0000000025030700 found in
_HEAP @ 1c60000
HEAP_ENTRY Size Prev Flags UserPtr UserSize - state
00000000250306d0 8006 0000 [00] 0000000025030700 80034 - (busy)
76efcc0d ntdll! ?? ::FNODOBFM::`string'+0x000000000001913b
fbaf4fd MSVCR100D!heap_alloc_base+0x000000000000005d
fbc1efd MSVCR100D!nh_malloc_dbg+0x00000000000003bd
fbc1c09 MSVCR100D!nh_malloc_dbg+0x00000000000000c9
fbc1b89 MSVCR100D!nh_malloc_dbg+0x0000000000000049
fbc617a MSVCR100D!malloc+0x000000000000002a
*** WARNING: Unable to verify checksum for D:\XXXXXXXXXX\XXXXXXXXXXXXXXX.dll
7febb5c37e1 XXXXXXXXX!XXXXXX::XXXXXXXXXXX::TransformPixelData+0x00000000000009a1
X 7febb5dca4c XXXXXXXXXXXXXXXXX!XXXXXXXXX::LogicProcess::UpdatePixelDataByPSR+0x000000000000017c
7febb5e07f5 XXXXXXXXXX!XXXXXXXXX::LogicProcess::RenderToOverlay+0x0000000000000055
7febb5df0b2 XXXXXXXXXXXXXX!XXXXXXXXXXXX::LogicProcess::ExportBySpecifiedMode+0x00000000000005b2
7feb800918f XXXXXXXXXXX!XXXXXXXXX::XXXXXXXXXXXXXXXXXX::ExportGSPSInfoBySpecifiedMode+0x0000000000000daf
7feb808fb89 XXXXXXXXXX!XXXXXXX::XXXXXXXXXX::storeSCU+0x0000000000000c29
7feb808e628 XXXXXXXXXXXX!XXXXXXXXXX::XXXXXXXXXX::DoRealStore+0x0000000000000438
7feb80a763a XXXXXXXXXXXXX!boost::_bi::list0::operator()<void (__cdecl*)(void),boost::_bi::list0>+0x000000000000003a
7feb80a75c1 XXXXXXXXXXXXX!boost::_bi::bind_t<void,void (__cdecl*)(void),boost::_bi::list0>::operator()+0x0000000000000061
7feb80a753f XXXXXXXXXXXXXXXX!boost::detail::thread_data<boost::_bi::bind_t<void,void (__cdecl*)(void),boost::_bi::list0> >::run+0x000000000000002f
7feb82ef7a7 XXXXXXXXXXXX!boost::`anonymous namespace'::thread_start_function+0x0000000000000037
fab72e5 MSVCR100D!beginthreadex+0x00000000000002d5
fab72a4 MSVCR100D!beginthreadex+0x0000000000000294
76d5652d kernel32!BaseThreadInitThunk+0x000000000000000d
76e8c521 ntdll!RtlUserThreadStart+0x000000000000001d
如何用windbg分析内存泄露的更多相关文章
- umdh windbg分析内存泄露
A.利用工具umdh(user-mode dump heap)分析:此处以程序MemoryLeak.exe为例子 1.开启cmd 键入要定位内存泄露的程序gflags.exe /i memroylea ...
- Android 性能优化之使用MAT分析内存泄露问题
我们平常在开发Android应用程序的时候,稍有不慎就有可能产生OOM,虽然JAVA有垃圾回收机,但也不能杜绝内存泄露,内存溢出等问题,随着科技的进步,移动设备的内存也越来越大了,但由于Android ...
- Eclipse Memory Analyzer 分析内存泄露
OutOfMemoryError示例 代码 package com.walson.heap; import java.util.ArrayList;import java.util.List; /** ...
- Android 性能优化之使用MAT分析内存泄露
转载请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/42396507),请尊重他人的辛勤劳动成果,谢谢! 我们平常 ...
- 使用MAT分析内存泄露
使用MAT分析内存泄露 对于大型服务端应用程序来说,有些内存泄露问题很难在测试阶段发现,此时就需要分析JVM Heap Dump文件来找出问题.随着单机内存越来越大,应用heap也开得越来越大,动辄十 ...
- 强大的windbg定位内存泄露,两句命令搞定!
1.简单配置在windbg程序目录下有个gflags.exe,运行后设置: 运行CMD.EXE,输入"D:\Debugging Tools for Windows (x86)\gflags. ...
- 使用AndroidStudio dump heap,再用 Eclipse MAT插件分析内存泄露
1.eclipse mat插件的安装 Help->Install new software,如下图,一直下一步即可 2.AndroidStudio dump heap 3.AndroidStud ...
- 【转】如何用WINDBG分析64位机上32位程序的DUMP文件
将dump拖入到windbg中后,在command输入栏输入 .load wow64exts 回车 !sw 回车,就将windbg的dump,从64位模式切换到了32位模式,否则看到的call sta ...
- jvm分析内存泄露
首页 所有文章 资讯 Web 架构 基础技术 书籍 教程 Java小组 工具资源 - 导航条 - 首页 所有文章 资讯 Web 架构 基础技术 书籍 教程 Java小组 工具资源 ...
随机推荐
- class_alias--为一个类创建别名
class_alias--为一个类创建别名 bool class_alias ( string $original , string $alias [, bool $autoload = TRUE ] ...
- [转载]allowTransparency属性
原文地址:allowTransparency属性作者:惊寒唱晚 IE5.5开始支持浮动框架的内容透明.如果想要为浮动框架定义透明内容,则必须满足下列条件. 1.与 iframe 元素一起使用的 all ...
- myEclipse 导入maven项目时报错
1.先右击项目,build Path 查看是否是某个JAR出了错.去掉无用的JAR 以及修改对应的JDK版本 2.检查src源文件,查看是否是源文件出了错.发现,还真的是 导入的包上面,报错:The ...
- Mac键盘图标与对应快捷按键标志汇总 分类
Mac键盘图标与对应快捷按键 ⌘——Command () win键 ⌃ ——Control ctrl键 ⌥——Option (alt) ⇧——Shift ⇪——Caps Lock fn——功能键就是 ...
- QT 学习记录:渐变-QLinearGradient,QRadialGradient,QConicalGradient)
http://blog.csdn.net/wangwei890702/article/details/8552482 QT:渐变 渐变,是指逐渐的,有规律性的变化,是一种规律性很强的现象.Qt提供了一 ...
- stanford推荐阅读目录
stanford deep learning 网站上推荐的阅读目录: UFLDL Recommended Readings If you're learning about UFLDL (Unsu ...
- alias 中使用awk
alias hehistory10='history |awk "{print \$2}"|sort|uniq -c|sort -rn|head -10' $要转义
- memcached telnet command
memcached telnet commandtelnet 127.0.0.1 11211 --连接memcached 1.基本命令1)set set 命令用于向缓存添加新的键值对.如果键已经存在, ...
- LeetCode OJ:Binary Tree Inorder Traversal(中序遍历二叉树)
Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...
- java对Hbase的基本操作
1.新建一个普通java项目,把${hbase}/lib/目录下的jar包全部导入 2.导出jar文件如下 3.运行 注意:需要先把jar文件导入到hbase路径里去,然后运行相应的类 4.查看数据 ...