2017-07-25 13 views
3

請注意以下幾點:dumpheap VS琴絃 - 不同的計數報道字符串的條目和不同長度的

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.

它們的長度是不同的。

爲什麼?

回答

2

我想我找到了答案。

都是由!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命令只是返回字符串中字符的計數。

+1

哇。我沒有想到。很好的結論。 –

相關問題