debugging - "!heap -flt -s xxxx"windbg命令中的不同列代表什么

标签 debugging heap-memory windbg

我一直在做一些关于高内存问题的工作,我一直在 windbg 中进行大量堆分析,我很好奇“!heap -flt -s xxxx”命令中不同列的真正含义。

我读了What do the 'size' numbers mean in the windbg !heap output? ,我查看了我的“Windows Internals”一书,但我仍然有很多问题。所以专栏和我的问题如下。

**HEAP_ENTRY** - What does this pointer really point to? How is it different than UserPtr?
**Size** - What does this size mean? How is it different than UserSize?
**Prev** - This just appears to be the negative offset to get to the previous heap entry. Still not sure exactly how it's used.
**Flags** - Is there any documentation on these flags?
**UserPtr** - What is the user pointer? In all cases I've seen it's always 8 bytes higher than the HEAP_ENTRY, but I don't really know what it points to.
**UserSize** - This appears to be the size of the actual allocation.
**state** - This just tells you what state of this heap entry is (free, busy, etc....)

Example:
HEAP_ENTRY Size Prev Flags    UserPtr UserSize - state
  0015eeb0 0044 0000  [07]   0015eeb8    00204 - (busy)

最佳答案

HEAP_ENTRY
堆将分配的 block 存储在连续的内存段中,每个分配的 block 以一个 8 字节的 header 开头,后跟实际分配的数据。 HEAP_ENTRY 列是分配 block 的头部的开始地址。

尺码
堆管理器以 8 个字节的倍数处理 block 。该列是分配的 8 字节 block 的数量。在您的示例中,0044 表示该 block 占用 0x220 字节(0x44*8)。

上一页
乘以 8 得到前一个堆 block 的负偏移量(以字节为单位)。

标志
这是对以下信息进行编码的位掩码

0x01 - HEAP_ENTRY_BUSY
0x02 - HEAP_ENTRY_EXTRA_PRESENT
0x04 - HEAP_ENTRY_FILL_PATTERN
0x08 - HEAP_ENTRY_VIRTUAL_ALLOC
0x10 - HEAP_ENTRY_LAST_ENTRY

用户指针
这是 HeapAlloc(由 malloc/new 调用)函数返回给应用程序的指针。由于 header 始终为 8 字节长,因此始终为 HEAP_ENTRY +8。

用户规模
这是通过 HeapAlloc 函数的大小。

状态
这是对 Flags 列的解码,告知条目是否繁忙、已释放、其段的最后一个,......

请注意,在 Windows 7/2008 R2 中,堆默认使用名为 LFH(低碎片堆)的前端,该前端使用默认堆管理器来分配 block ,在其中分派(dispatch)用户分配的数据。对于这些堆,UserPtr 和 UserSize 不会指向真实的用户数据。!heap -s 的输出显示哪些堆启用了 LFH。

关于debugging - "!heap -flt -s xxxx"windbg命令中的不同列代表什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6687414/

相关文章:

python - 如何将脚本参数传递给 pdb (Python)?

c - malloc() 和 free() 在哪里存储分配的大小和地址?

Java 堆转储(hprof 文件)比常驻内存小得多

windows - windbg:私有(private) pdb 符号

.net-core - WinDbg+SOS : How to view the . NET 对象包装句柄?

objective-c - 在 iOS 上调试线程安全问题

javascript - JSON.parse(JSON.stringify(e)) 将对象转换为字符串

java - keyReleases 在 Linux 中模拟 keyPresses (java Swing GUI)

java - 原始包装器内存空间开销与泛型,在 Java 中

windows - 为意外停止的 Windows 服务生成内存转储