windbg - !dumpheap vs !strings - 不同的条目数和不同长度的报告字符串

标签 windbg

请注意:

0:000> !dumpheap -min 0n100000 -mt 00007fff6c9c16b8 -live
         Address               MT     Size
0000009757e51038 00007fff6c9c16b8   116590     
0000009757e6d7c8 00007fff6c9c16b8   121392     
0000009757e8b218 00007fff6c9c16b8   160838     
0000009757eb2680 00007fff6c9c16b8   160826     
0000009757ed9ae0 00007fff6c9c16b8   179332     
0000009767e51038 00007fff6c9c16b8   121516     
0000009767e6eb08 00007fff6c9c16b8   129002     
0000009767e8e318 00007fff6c9c16b8   154506     
0000009767eb3ec8 00007fff6c9c16b8   153568     
0000009767ed96c8 00007fff6c9c16b8   212294     
0000009767f223e0 00007fff6c9c16b8   211356     
0000009767f55da0 00007fff6c9c16b8   157274     
0000009767f7c420 00007fff6c9c16b8   156336     
0000009767fa26f0 00007fff6c9c16b8   215062     
0000009767fd6f28 00007fff6c9c16b8   214124     
0000009777e71070 00007fff6c9c16b8   130594     

Statistics:
              MT    Count    TotalSize Class Name
00007fff6c9c16b8       16      2594610 System.String
Total 16 objects
0:000> !strings /n:100000
Address            Gen    Length   Value
---------------------------------------
0000009767ed96c8   LOH    106134   
                SET DEADLOCK_PRIORITY HIGH

                DECLARE @CommittedCommitStateId INT = (Select PR...
0000009767f223e0   LOH    105665   
                SET DEADLOCK_PRIORITY HIGH

                DECLARE @CommittedCommitStateId INT = (Select PR...
0000009767fa26f0   LOH    107518   
                SET DEADLOCK_PRIORITY HIGH

                DECLARE @CommittedCommitStateId INT = (Select PR...
0000009767fd6f28   LOH    107049   
                SET DEADLOCK_PRIORITY HIGH

                DECLARE @CommittedCommitStateId INT = (Select PR...
---------------------------------------
4 matching strings

请注意,!dumpheap 报告 16 个事件字符串,而 !strings 仅报告 4 个。

并且它们的长度不同。

为什么?

最佳答案

我想我找到了答案。

!stringsdumpheap 找到的 4 个字符串具有不同的长度,具体取决于使用的命令:

Address            Length by !dumpheap   Length by !strings         
0000009767ed96c8   212294                106134   
0000009767f223e0   211356                105665
0000009767fa26f0   215062                107518
0000009767fd6f28   214124                107049

地点:

212294 = 106134 * 2 + 26
211356 = 105665 * 2 + 26
215062 = 107518 * 2 + 26
214124 = 107049 * 2 + 26

所以,这是我的假设 - !dumpheap 报告 .NET 字符串的原始大小 - 这意味着它使字符数加倍,并将字符串对象的任何额外字段相​​加。 !strings 命令只返回字符串中的字符数。

关于windbg - !dumpheap vs !strings - 不同的条目数和不同长度的报告字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45315115/

相关文章:

c - 重叠结构和 LARGE_INTEGER

windows - WinDbg 显示一些变量但不显示其他变量,在同一位置显示一些变量

windows - *** 错误 : Symbol file could not be found. 默认导出 ntkrnlmp.exe 的符号

c - strtok_s 在 Windbg 中返回不正确的数据

memory-leaks - 在断点处记录调用堆栈和值?

c++ - 是否可以在不崩溃的情况下以编程方式创建迷你转储文件?

c# - 如何修复 windbg 执行中显示的这个异常?

c# - 调试 Windows Phone 应用程序时无法理解此 Windbg 输出

c++ - "Attempt to execute non-executable address"是什么意思?

asp.net - 使用 WinDbg 和 ADPlus 帮助捕获 StackOverflowException