1 namespace Example_11_1_1 2 { 3 internal class Program 4 { 5 static void Main(string[] args) 6 { 7 byte[] byte1 = new byte[10000]; 8 byte[] byet2 = new byte[85000]; 9 Console.WriteLine("Hello world!"); 10 Console.ReadLine(); 11 } 12 } 13 }
1 namespace Example_11_1_3 2 { 3 internal class Program 4 { 5 static void Main(string[] args) 6 { 7 byte[] byte1 = new byte[85000]; 8 byte[] byte2 = new byte[1500]; 9 byte[] byet3 = new byte[3500]; 10 Console.WriteLine("3 個 byte[] 分配完畢!"); 11 Console.ReadLine(); 12 } 13 } 14 }
1 0:006> !address -summary 2 3 4 Mapping file section regions... 5 Mapping module regions... 6 Mapping PEB regions... 7 Mapping TEB and stack regions... 8 Mapping heap regions... 9 Mapping page heap regions... 10 Mapping other regions... 11 Mapping stack trace database regions... 12 Mapping activation context regions... 13 14 --- Usage Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal 15 Free 57 f852b000 ( 3.880 GB) 97.00% 16 Image 191 2eb9000 ( 46.723 MB) 38.06% 1.14% 17 <unknown> 88 2670000 ( 38.438 MB) 31.31% 0.94% 18 MappedFile 18 1cec000 ( 28.922 MB) 23.56% 0.71% 19 Stack 21 700000 ( 7.000 MB) 5.70% 0.17% 20 Heap 10 13b000 ( 1.230 MB) 1.00% 0.03% 21 Other 7 5c000 ( 368.000 kB) 0.29% 0.01% 22 TEB 7 16000 ( 88.000 kB) 0.07% 0.00% 23 PEB 1 3000 ( 12.000 kB) 0.01% 0.00% 24 25 --- Type Summary (for busy) ------ RgnCount ----------- Total Size -------- %ofBusy %ofTotal 26 MEM_IMAGE 198 2ec3000 ( 46.762 MB) 38.09% 1.14% 27 MEM_PRIVATE 122 2ebc000 ( 46.734 MB) 38.07% 1.14% 28 MEM_MAPPED 23 1d46000 ( 29.273 MB) 23.84% 0.71% 29 30 --- State Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal 31 MEM_FREE 57 f852b000 ( 3.880 GB) 97.00% 32 MEM_RESERVE 65 43a4000 ( 67.641 MB) 55.10% 1.65% 33 MEM_COMMIT 278 3721000 ( 55.129 MB) 44.90% 1.35% 34 35 --- Protect Summary (for commit) - RgnCount ----------- Total Size -------- %ofBusy %ofTotal 36 PAGE_EXECUTE_READ 32 25b2000 ( 37.695 MB) 30.70% 0.92% 37 PAGE_READONLY 90 bae000 ( 11.680 MB) 9.51% 0.29% 38 PAGE_WRITECOPY 30 399000 ( 3.598 MB) 2.93% 0.09% 39 PAGE_READWRITE 102 1f8000 ( 1.969 MB) 1.60% 0.05% 40 PAGE_READWRITE | PAGE_GUARD 16 28000 ( 160.000 kB) 0.13% 0.00% 41 PAGE_EXECUTE_READWRITE 8 8000 ( 32.000 kB) 0.03% 0.00% 42 43 --- Largest Region by Usage ----------- Base Address -------- Region Size ---------- 44 Free 80010000 7f2f0000 ( 1.987 GB) 45 Image 6de80000 f55000 ( 15.332 MB) 46 <unknown> 2f22000 fee000 ( 15.930 MB) 47 MappedFile 19d4000 133d000 ( 19.238 MB) 48 Stack 1410000 fd000 (1012.000 kB) 49 Heap f20000 8b000 ( 556.000 kB) 50 Other ff480000 33000 ( 204.000 kB) 51 TEB ce1000 4000 ( 16.000 kB) 52 PEB ccc000 3000 ( 12.000 kB)
輸出的內容還是不少的,列表中【Heap 10 13b000 ( 1.230 MB) 1.00% 0.03%】,這個就是 NT 堆。
我們也可以使用【!heap -s】命令,檢視 NT 堆的詳情。
1 0:006> !heap -s 2 3 4 ************************************************************************************************************************ 5 NT HEAP STATS BELOW 6 ************************************************************************************************************************ 7 NtGlobalFlag enables following debugging aids for new heaps: 8 tail checking 9 free checking 10 validate parameters 11 LFH Key : 0x0afd8ea9 12 Termination on corruption : ENABLED 13 Heap Flags Reserv Commit Virt Free List UCR Virt Lock Fast 14 (k) (k) (k) (k) length blocks cont. heap 15 ----------------------------------------------------------------------------- 16 00f20000 40000062 1020 556 1020 6 65 1 0 4 (第一個堆是程序堆,是 Win32函數用的) 17 01200000 40001062 60 12 60 1 2 1 0 0 18 01570000 40001062 60 12 60 1 2 1 0 0 19 02f00000 40001062 60 4 60 0 1 1 0 0 20 01540000 40041062 60 4 60 2 1 1 0 0 21 -----------------------------------------------------------------------------
2)、我們檢視一下 GC 堆。
如果我們想檢視 GC 堆,可以直接使用【!eeheap -gc】命令。
1 0:006> !eeheap -gc 2 Number of GC Heaps: 1 3 generation 0 starts at 0x02f11018 4 generation 1 starts at 0x02f1100c 5 generation 2 starts at 0x02f11000 6 ephemeral segment allocation context: none 7 segment begin allocated size 8 02f10000 02f11000 02f1871c 0x771c(30492) 9 Large object heap starts at 0x03f11000 10 segment begin allocated size 11 03f10000 03f11000 03f2a180 0x19180(102784) 12 Total Size: Size: 0x2089c (133276) bytes. 13 ------------------------------ 14 GC Heap Size: Size: 0x2089c (133276) bytes.
1 0:006> !eeheap -gc 2 Number of GC Heaps: 1 3 generation 0 starts at 0x02f11018 4 generation 1 starts at 0x02f1100c 5 generation 2 starts at 0x02f11000 6 ephemeral segment allocation context: none 7 segment begin allocated size 8 02f10000 02f11000 02f1871c 0x771c(30492) 9 Large object heap starts at 0x03f11000(這個就是大物件堆) 10 segment begin allocated size 11 03f10000 03f11000 03f2a180 0x19180(102784) 12 Total Size: Size: 0x2089c (133276) bytes. 13 ------------------------------ 14 GC Heap Size: Size: 0x2089c (133276) bytes.
我們再使用【!dumpheap 03f11000 03f2a180】檢視一下大物件堆的情況。
0:006> !dumpheap 03f11000 03f2a180 Address MT Size 03f11000 00f45368 10 Free 03f11010 00f45368 14 Free 03f11020 6dae2788 4872 03f12328 00f45368 14 Free 03f12338 6dae2788 524 03f12548 00f45368 14 Free 03f12558 6dae2788 4092 03f13558 00f45368 14 Free 03f13568 6dae2788 8172 03f15558 00f45368 14 Free 03f15568 6dae5c40 85012 Statistics: MT Count TotalSize Class Name 00f45368 6 80 Free 6dae2788 4 17660 System.Object[] 6dae5c40 1 85012 System.Byte[] Total 11 objects
紅色標註的就是我們的 byte 陣列,大小是 85012,為什麼多了12,陣列是參照型別,參照型別都有兩個附加欄位(8)和一個陣列長度(4)的欄位,共12,再加上陣列的長度就是85012。
我們確認了 byet2 確實是在大物件堆中,我們繼續看看 byet1是不是在小物件堆中。使用相同的命令【!dumpheap 02f11000 02f1871c】,這個地址就是小物件堆的起始地址和結束地址,就是【ephemeral segment allocation】臨時段。
1 0:006> !dumpheap 02f11000 02f1871c 2 Address MT Size 3 02f11000 00f45368 10 Free 4 02f1100c 00f45368 10 Free 5 ..... 6 02f124fc 00f45368 10 Free 7 02f12508 6dae5c40 10012 8 02f14c24 6dae8b20 28 9 ..... 10 02f174f4 6db49b0c 16 11 12 Statistics: 13 MT Count TotalSize Class Name 14 ...... 15 6dae5c40 4 10818 System.Byte[] 16 Total 325 objects
紅色標記的就是 byte 陣列,我們使用【!DumpHeap /d -mt 6dae5c40】檢視詳情。
1 0:006> !DumpHeap /d -mt 6dae5c40 2 Address MT Size 3 02f12508 6dae5c40 10012 4 02f16710 6dae5c40 526 5 02f171cc 6dae5c40 268 6 02f174e8 6dae5c40 12 7 03f15568 6dae5c40 85012 8 9 Statistics: 10 MT Count TotalSize Class Name 11 6dae5c40 5 95830 System.Byte[] 12 Total 5 objects
紅色標記的就是我們的 byte1 byte 陣列。當然,我們可以使用命令【!do】檢視詳情。
1 0:006> !do 02f12508 2 Name: System.Byte[] 3 MethodTable: 6dae5c40 4 EEClass: 6dbe8ba8 5 Size: 10012(0x271c) bytes 6 Array: Rank 1, Number of elements 10000, Type Byte (Print Array) 7 Content: ................................................................................................................................ 8 Fields: 9 None
1 0:006> !eeheap -gc 2 Number of GC Heaps: 1 3 generation 0 starts at 0x02f11018(0代) 4 generation 1 starts at 0x02f1100c(1代) 5 generation 2 starts at 0x02f11000(2代) 6 ephemeral segment allocation context: none 7 segment begin allocated size 8 02f10000 02f11000 02f1871c 0x771c(30492) 9 Large object heap starts at 0x03f11000 10 segment begin allocated size 11 03f10000 03f11000 03f2a180 0x19180(102784) 12 Total Size: Size: 0x2089c (133276) bytes. 13 ------------------------------ 14 GC Heap Size: Size: 0x2089c (133276) bytes.
1 0:006> !eeversion 2 4.8.4300.0 retail 3 Workstation mode(工作站模式) 4 SOS Version: 4.8.4300.0 retail build
我們也可以通過【!eeheap -gc】命令檢視託管堆的個數檢視。
1 0:006> !eeheap -gc 2 Number of GC Heaps: 1(只有一個託管堆,就是工作站模式) 3 generation 0 starts at 0x02f11018 4 generation 1 starts at 0x02f1100c 5 generation 2 starts at 0x02f11000 6 ephemeral segment allocation context: none 7 segment begin allocated size 8 02f10000 02f11000 02f1871c 0x771c(30492) 9 Large object heap starts at 0x03f11000 10 segment begin allocated size 11 03f10000 03f11000 03f2a180 0x19180(102784) 12 Total Size: Size: 0x2089c (133276) bytes. 13 ------------------------------ 14 GC Heap Size: Size: 0x2089c (133276) bytes.
如果你使用的是【Debug】執行的 WEBAPI,偵錯會失敗,附加程序有誤,如圖:
在 Windbg中提示的具體錯誤:"The process that you are attempting to attach to is already being debugged. Only one debugger can be invasively attached to a process at a time. A non-invasive attach is still possible when another debugger is attached." ,意思就是:嘗試附加到的程序已在偵錯中。一次只能將一個偵錯程式侵入性附加到程序。把程式的執行模式改為【Release】模式,不用使用偵錯模式,快捷鍵:Ctrl+F5,就可以附加程序成功了。
我們可以使用【!eeheap -gc】命令檢視一下伺服器GC模式。
1 0:037> !eeheap -gc 2 Number of GC Heaps: 4(有四個堆,這既是伺服器GC模式) 3 ------------------------------ 4 Heap 0 (000001ff28a2dc70) 5 generation 0 starts at 0x000001ff29283e08 6 generation 1 starts at 0x000001ff29121018 7 generation 2 starts at 0x000001ff29121000 8 ephemeral segment allocation context: none 9 segment begin allocated size 10 000001ff29120000 000001ff29121000 000001ff2a79a728 0x1679728(23566120) 11 Large object heap starts at 0x0000020329121000 12 segment begin allocated size 13 0000020329120000 0000020329121000 000002032941f2c0 0x2fe2c0(3138240) 14 Heap Size: Size: 0x19779e8 (26704360) bytes. 15 ------------------------------ 16 Heap 1 (000001ff28a5dc40) 17 generation 0 starts at 0x000002002923b6d0 18 generation 1 starts at 0x0000020029121018 19 generation 2 starts at 0x0000020029121000 20 ephemeral segment allocation context: none 21 segment begin allocated size 22 0000020029120000 0000020029121000 000002002a755fe8 0x1634fe8(23285736) 23 Large object heap starts at 0x0000020339121000 24 segment begin allocated size 25 0000020339120000 0000020339121000 00000203392c8ff0 0x1a7ff0(1736688) 26 Heap Size: Size: 0x17dcfd8 (25022424) bytes. 27 ------------------------------ 28 Heap 2 (000001ff28a87bf0) 29 generation 0 starts at 0x00000201291ebe00 30 generation 1 starts at 0x0000020129121018 31 generation 2 starts at 0x0000020129121000 32 ephemeral segment allocation context: none 33 segment begin allocated size 34 0000020129120000 0000020129121000 000002012993ffe8 0x81efe8(8515560) 35 Large object heap starts at 0x0000020349121000 36 segment begin allocated size 37 0000020349120000 0000020349121000 0000020349121018 0x18(24) 38 Heap Size: Size: 0x81f000 (8515584) bytes. 39 ------------------------------ 40 Heap 3 (000001ff28ab1ba0) 41 generation 0 starts at 0x00000202291ebab8 42 generation 1 starts at 0x0000020229121018 43 generation 2 starts at 0x0000020229121000 44 ephemeral segment allocation context: none 45 segment begin allocated size 46 0000020229120000 0000020229121000 000002022a711fe8 0x15f0fe8(23007208) 47 Large object heap starts at 0x0000020359121000 48 segment begin allocated size 49 0000020359120000 0000020359121000 00000203592d9ec8 0x1b8ec8(1806024) 50 Heap Size: Size: 0x17a9eb0 (24813232) bytes. 51 ------------------------------ 52 GC Heap Size: Size: 0x511d870 (85055600) bytes.
當然,我們也可以使用【!eeversion】檢視 GC 的模式。
1 0:037> !eeversion 2 4.8.4300.0 free 3 Server mode with 4 gc heaps(伺服器模式) 4 SOS Version: 4.8.4300.0 retail build
我的機器當前又4個CPU,截圖如下:
所以,伺服器 GC 模式就有 4個 託管堆。
2.6、【!dumpheap】命令使用簡介1 0:006> !dumpheap -min 0n1000 -max 0n2000 2 Address MT Size 3 03372514 6da95c40 1512 4 03375690 6da92c60 1660 5 6 Statistics: 7 MT Count TotalSize Class Name 8 6da95c40 1 1512 System.Byte[] 9 6da92c60 1 1660 System.Char[] 10 Total 2 objects
我們再來一個錯誤的演示,把0n去掉,執行如下;
1 0:006> !dumpheap -min 1000 -max 2000 2 Address MT Size 3 04371020 6da92788 4872 4 04373568 6da92788 8172 5 6 Statistics: 7 MT Count TotalSize Class Name 8 6da92788 2 13044 System.Object[] 9 Total 2 objects
把 0n 去掉,我們看看1000和2000是多少。
1 0:006> ? 1000 2 Evaluate expression: 4096 = 00001000 3 0:006> ? 2000 4 Evaluate expression: 8192 = 00002000
看到了把,查詢的範圍就是4000多到8000多,意思就不對了,所以一定要加上 0n。
1 0:006> !dumpheap -min 0n1000 2 Address MT Size 3 03372514 6da95c40 1512 4 03372afc 6da95c40 3512 5 03375690 6da92c60 1660 6 04371020 6da92788 4872 7 04372558 6da92788 4092 8 04373568 6da92788 8172 9 04375568 6da95c40 85012 10 11 Statistics: 12 MT Count TotalSize Class Name 13 6da92c60 1 1660 System.Char[] 14 6da92788 3 17136 System.Object[] 15 6da95c40 3 90036 System.Byte[] 16 Total 7 objects
都是我們要查詢的物件。
1 0:006> !dumpheap -stat 2 Statistics: 3 MT Count TotalSize Class Name 4 6da95468 1 12 System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib]] 5 ...... 6 6da924e4 166 5926 System.String 7 6da92788 6 17748 System.Object[] 8 6da95c40 6 90842 System.Byte[] 9 Total 337 objects
紅色標記的我們要查詢的字串。
1 0:006> !dumpheap -type string 2 Address MT Size 3 4 Statistics: 5 MT Count TotalSize Class Name 6 Total 0 objects 7 0:006> !dumpheap -type String 8 Address MT Size 9 03371228 6da924e4 14 10 03371254 6da924e4 208 11 03371324 6da924e4 258 12 03371498 6da924e4 22 13 033714b0 6da924e4 78 14 03371544 6da924e4 244 15 03371638 6da924e4 28 16 03371664 6da924e4 50 17 03371698 6da92d74 84 18 033716ec 6da924e4 208 19 033717bc 6da924e4 64 20 033717fc 6da924e4 28 21 03371818 6da924e4 16 22 03371828 6da924e4 38 23 03371850 6da924e4 44 24 0337187c 6da924e4 46 25 033718ac 6da924e4 34 26 033718d0 6da924e4 28 27 033718ec 6da924e4 30 28 0337190c 6da924e4 38 29 03371934 6da924e4 58 30 03371970 6da924e4 58 31 033719ac 6da924e4 64 32 033719ec 6da924e4 52 33 03371a20 6da924e4 50 34 03371a54 6da924e4 44 35 03371a80 6da924e4 44 36 03371aac 6da924e4 30 37 03371acc 6da924e4 42 38 03371af8 6da924e4 56 39 03371b30 6da924e4 36 40 03371b54 6da924e4 24 41 03371b6c 6da924e4 106 42 03371bd8 6da924e4 148 43 03371c6c 6da924e4 78 44 03371cbc 6da924e4 70 45 03371d04 6da924e4 82 46 03372494 6da924e4 66 47 033724d8 6da92d74 12 48 033724e4 6da924e4 46 49 033738f0 6da924e4 16 50 03373a04 6da924e4 40 51 03373aac 6da924e4 30 52 03373acc 6da924e4 26 53 03373b60 6da924e4 78 54 03373bf8 6da924e4 16 55 03373c08 6da924e4 16 56 03373c18 6da924e4 16 57 03373c28 6da924e4 16 58 03373c38 6da924e4 90 59 03373c94 6da924e4 18 60 03373ca8 6da924e4 50 61 03373cdc 6da924e4 18 62 03373cf0 6da924e4 48 63 03373d20 6da924e4 16 64 03373d30 6da924e4 16 65 03373d40 6da924e4 16 66 03373d50 6da924e4 16 67 03373d60 6da924e4 16 68 03373d70 6da924e4 16 69 03373d80 6da924e4 16 70 03373d90 6da924e4 16 71 03373da0 6da924e4 16 72 03373db0 6da924e4 16 73 03373dc0 6da924e4 16 74 03373dd0 6da924e4 20 75 03373de4 6da924e4 30 76 03373e04 6da924e4 32 77 03373e24 6da924e4 16 78 03373e34 6da924e4 16 79 03373e44 6da924e4 16 80 03373e54 6da924e4 20 81 03373e68 6da924e4 68 82 03373eac 6da924e4 18 83 03373ec0 6da924e4 18 84 03373ed4 6da924e4 30 85 03373ef4 6da924e4 24 86 03373f0c 6da924e4 30 87 03373f2c 6da924e4 22 88 03373f44 6da924e4 28 89 03373f60 6da924e4 24 90 03373f78 6da924e4 20 91 03373f8c 6da924e4 20 92 03373fa0 6da924e4 20 93 03373fb4 6da924e4 20 94 03373fd4 6da924e4 40 95 03373ffc 6da924e4 114 96 033741bc 6da92d74 52 97 03374210 6da92d74 16 98 03374220 6da92d74 28 99 0337423c 6da92d74 16 100 033742c4 6da924e4 50 101 033742f8 6da924e4 34 102 0337431c 6da924e4 34 103 03374340 6da924e4 50 104 03374374 6da924e4 32 105 03374394 6da924e4 28 106 033743b0 6da924e4 22 107 033743c8 6da924e4 18 108 033743dc 6da924e4 26 109 033743f8 6da924e4 26 110 03374414 6da924e4 28 111 03374430 6da924e4 32 112 03374450 6da924e4 30 113 03374470 6da924e4 26 114 0337448c 6da924e4 30 115 033744ac 6da924e4 20 116 033744c0 6da924e4 20 117 033744d4 6da924e4 20 118 033744e8 6da924e4 20 119 033744fc 6da924e4 20 120 03374510 6da924e4 20 121 03374524 6da924e4 20 122 03374538 6da924e4 18 123 0337454c 6da924e4 18 124 03374560 6da924e4 18 125 03374574 6da924e4 18 126 03374588 6da924e4 18 127 0337459c 6da924e4 18 128 033745b0 6da924e4 18 129 033745c4 6da924e4 28 130 033745e0 6da924e4 30 131 03374600 6da924e4 24 132 03374618 6da924e4 24 133 03374630 6da924e4 20 134 03374644 6da924e4 22 135 0337465c 6da924e4 22 136 03374674 6da924e4 26 137 03374690 6da924e4 32 138 033746b0 6da924e4 28 139 033746cc 6da924e4 30 140 033746ec 6da924e4 30 141 0337470c 6da924e4 20 142 03374720 6da924e4 20 143 03374734 6da924e4 20 144 03374748 6da924e4 20 145 0337475c 6da924e4 20 146 03374770 6da924e4 20 147 03374784 6da924e4 20 148 03374798 6da924e4 20 149 033747ac 6da924e4 20 150 033747c0 6da924e4 20 151 033747d4 6da924e4 20 152 0337483c 6da92d74 20 153 03374850 6da92d74 16 154 03374860 6da92d74 16 155 03374870 6da92d74 16 156 03374880 6da92d74 16 157 03374890 6da92d74 16 158 033748a0 6da92d74 40 159 033748c8 6da92d74 40 160 033748f0 6da92d74 40 161 03374918 6da92d74 64 162 03374958 6da92d74 64 163 03374998 6da924e4 26 164 033749b4 6da924e4 26 165 033749d0 6da924e4 24 166 03374a30 6da9524c 28 167 03374a64 6da924e4 24 168 03374a7c 6da952a0 48 169 03374ae4 6da95468 12 170 03374c24 6da924e4 24 171 03374c3c 6da924e4 24 172 03374c54 6da924e4 24 173 03374c6c 6da924e4 24 174 03374c84 6da924e4 24 175 03374c9c 6da924e4 24 176 03374cd8 6da955bc 60 177 03374d14 6da924e4 24 178 03374d88 6da924e4 26 179 03374da4 6da924e4 22 180 03374df4 6da9524c 28 181 03374fb4 6da92d74 52 182 03374fe8 6da924e4 16 183 03374ff8 6da924e4 20 184 0337500c 6da924e4 16 185 0337501c 6da924e4 16 186 0337502c 6da924e4 16 187 0337503c 6da924e4 16 188 0337504c 6da924e4 62 189 0337512c 6da924e4 30 190 0337514c 6da924e4 26 191 033755b0 6da924e4 24 192 033755c8 6da924e4 24 193 033755e0 6da924e4 32 194 03375600 6da924e4 32 195 03375620 6da924e4 32 196 03375d98 6da924e4 24 197 03375db0 6da924e4 26 198 199 Statistics: 200 MT Count TotalSize Class Name 201 6da95468 1 12 System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib]] 202 6da952a0 1 48 System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Globalization.CultureData, mscorlib]] 203 6da9524c 2 56 System.Text.StringBuilder 204 6da955bc 1 60 System.Collections.Generic.Dictionary`2+Entry[[System.String, mscorlib],[System.Globalization.CultureData, mscorlib]][] 205 6da92d74 18 608 System.String[] 206 6da924e4 166 5926 System.String 207 Total 189 objects
字串物件還是挺多的,如果想看效果,可以點開檢視。
當然,如果我們知道字串的方法表,也可以找到的到,這個樣更精確。【!dumpheap -type String】是模糊查詢,所有和字串相關都會找到,我們使用【!dumpheap -mt 6da924e4】,這個才最準確。
1 0:006> !dumpheap -mt 6da924e4 2 Address MT Size 3 03371228 6da924e4 14 4 03371254 6da924e4 208 5 03371324 6da924e4 258 6 03371498 6da924e4 22 7 033714b0 6da924e4 78 8 03371544 6da924e4 244 9 03371638 6da924e4 28 10 03371664 6da924e4 50 11 033716ec 6da924e4 208 12 033717bc 6da924e4 64 13 033717fc 6da924e4 28 14 03371818 6da924e4 16 15 03371828 6da924e4 38 16 03371850 6da924e4 44 17 0337187c 6da924e4 46 18 033718ac 6da924e4 34 19 033718d0 6da924e4 28 20 033718ec 6da924e4 30 21 0337190c 6da924e4 38 22 03371934 6da924e4 58 23 03371970 6da924e4 58 24 033719ac 6da924e4 64 25 033719ec 6da924e4 52 26 03371a20 6da924e4 50 27 03371a54 6da924e4 44 28 03371a80 6da924e4 44 29 03371aac 6da924e4 30 30 03371acc 6da924e4 42 31 03371af8 6da924e4 56 32 03371b30 6da924e4 36 33 03371b54 6da924e4 24 34 03371b6c 6da924e4 106 35 03371bd8 6da924e4 148 36 03371c6c 6da924e4 78 37 03371cbc 6da924e4 70 38 03371d04 6da924e4 82 39 03372494 6da924e4 66 40 033724e4 6da924e4 46 41 033738f0 6da924e4 16 42 03373a04 6da924e4 40 43 03373aac 6da924e4 30 44 03373acc 6da924e4 26 45 03373b60 6da924e4 78 46 03373bf8 6da924e4 16 47 03373c08 6da924e4 16 48 03373c18 6da924e4 16 49 03373c28 6da924e4 16 50 03373c38 6da924e4 90 51 03373c94 6da924e4 18 52 03373ca8 6da924e4 50 53 03373cdc 6da924e4 18 54 03373cf0 6da924e4 48 55 03373d20 6da924e4 16 56 03373d30 6da924e4 16 57 03373d40 6da924e4 16 58 03373d50 6da924e4 16 59 03373d60 6da924e4 16 60 03373d70 6da924e4 16 61 03373d80 6da924e4 16 62 03373d90 6da924e4 16 63 03373da0 6da924e4 16 64 03373db0 6da924e4 16 65 03373dc0 6da924e4 16 66 03373dd0 6da924e4 20 67 03373de4 6da924e4 30 68 03373e04 6da924e4 32 69 03373e24 6da924e4 16 70 03373e34 6da924e4 16 71 03373e44 6da924e4 16 72 03373e54 6da924e4 20 73 03373e68 6da924e4 68 74 03373eac 6da924e4 18 75 03373ec0 6da924e4 18 76 03373ed4 6da924e4 30 77 03373ef4 6da924e4 24 78 03373f0c 6da924e4 30 79 03373f2c 6da924e4 22 80 03373f44 6da924e4 28 81 03373f60 6da924e4 24 82 03373f78 6da924e4 20 83 03373f8c 6da924e4 20 84 03373fa0 6da924e4 20 85 03373fb4 6da924e4 20 86 03373fd4 6da924e4 40 87 03373ffc 6da924e4 114 88 033742c4 6da924e4 50 89 033742f8 6da924e4 34 90 0337431c 6da924e4 34 91 03374340 6da924e4 50 92 03374374 6da924e4 32 93 03374394 6da924e4 28 94 033743b0 6da924e4 22 95 033743c8 6da924e4 18 96 033743dc 6da924e4 26 97 033743f8 6da924e4 26 98 03374414 6da924e4 28 99 03374430 6da924e4 32 100 03374450 6da924e4 30 101 03374470 6da924e4 26 102 0337448c 6da924e4 30 103 033744ac 6da924e4 20 104 033744c0 6da924e4 20 105 033744d4 6da924e4 20 106 033744e8 6da924e4 20 107 033744fc 6da924e4 20 108 03374510 6da924e4 20 109 03374524 6da924e4 20 110 03374538 6da924e4 18 111 0337454c 6da924e4 18 112 03374560 6da924e4 18 113 03374574 6da924e4 18 114 03374588 6da924e4 18 115 0337459c 6da924e4 18 116 033745b0 6da924e4 18 117 033745c4 6da924e4 28 118 033745e0 6da924e4 30 119 03374600 6da924e4 24 120 03374618 6da924e4 24 121 03374630 6da924e4 20 122 03374644 6da924e4 22 123 0337465c 6da924e4 22 124 03374674 6da924e4 26 125 03374690 6da924e4 32 126 033746b0 6da924e4 28 127 033746cc 6da924e4 30 128 033746ec 6da924e4 30 129 0337470c 6da924e4 20 130 03374720 6da924e4 20 131 03374734 6da924e4 20 132 03374748 6da924e4 20 133 0337475c 6da924e4 20 134 03374770 6da924e4 20 135 03374784 6da924e4 20 136 03374798 6da924e4 20 137 033747ac 6da924e4 20 138 033747c0 6da924e4 20 139 033747d4 6da924e4 20 140 03374998 6da924e4 26 141 033749b4 6da924e4 26 142 033749d0 6da924e4 24 143 03374a64 6da924e4 24 144 03374c24 6da924e4 24 145 03374c3c 6da924e4 24 146 03374c54 6da924e4 24 147 03374c6c 6da924e4 24 148 03374c84 6da924e4 24 149 03374c9c 6da924e4 24 150 03374d14 6da924e4 24 151 03374d88 6da924e4 26 152 03374da4 6da924e4 22 153 03374fe8 6da924e4 16 154 03374ff8 6da924e4 20 155 0337500c 6da924e4 16 156 0337501c 6da924e4 16 157 0337502c 6da924e4 16 158 0337503c 6da924e4 16 159 0337504c 6da924e4 62 160 0337512c 6da924e4 30 161 0337514c 6da924e4 26 162 033755b0 6da924e4 24 163 033755c8 6da924e4 24 164 033755e0 6da924e4 32 165 03375600 6da924e4 32 166 03375620 6da924e4 32 167 03375d98 6da924e4 24 168 03375db0 6da924e4 26 169 170 Statistics: 171 MT Count TotalSize Class Name 172 6da924e4 166 5926 System.String 173 Total 166 objects
d)、我們可以搜尋大物件堆或者小物件堆中的物件,我們可以執行【!dumpheap】命令,命令後可以跟 Segment 段的開始和結束地址。
我們檢視小物件堆的物件。
1 0:006> !eeheap -gc 2 Number of GC Heaps: 1 3 generation 0 starts at 0x03371018 4 generation 1 starts at 0x0337100c 5 generation 2 starts at 0x03371000 6 ephemeral segment allocation context: none 7 segment begin allocated size 8 03370000 03371000 03377ff4 0x6ff4(28660) 9 Large object heap starts at 0x04371000 10 segment begin allocated size 11 04370000 04371000 0438a180 0x19180(102784) 12 Total Size: Size: 0x20174 (131444) bytes. 13 ------------------------------ 14 GC Heap Size: Size: 0x20174 (131444) bytes. 15 16 17 0:006> !dumpheap 03371000 03377ff4 18 Address MT Size 19 03371000 015c4e80 10 Free 20 0337100c 015c4e80 10 Free 21 03371018 015c4e80 10 Free 22 。。。。。。。
我們檢視大物件堆的物件。
1 0:006> !eeheap -gc 2 Number of GC Heaps: 1 3 generation 0 starts at 0x03371018 4 generation 1 starts at 0x0337100c 5 generation 2 starts at 0x03371000 6 ephemeral segment allocation context: none 7 segment begin allocated size 8 03370000 03371000 03377ff4 0x6ff4(28660) 9 Large object heap starts at 0x04371000 10 segment begin allocated size 11 04370000 04371000 0438a180 0x19180(102784) 12 Total Size: Size: 0x20174 (131444) bytes. 13 ------------------------------ 14 GC Heap Size: Size: 0x20174 (131444) bytes. 15 0:006> !dumpheap 04371000 0438a180 16 Address MT Size 17 04371000 015c4e80 10 Free 18 04371010 015c4e80 14 Free 19 04371020 6da92788 4872 20 04372328 015c4e80 14 Free 21 04372338 6da92788 524 22 04372548 015c4e80 14 Free 23 04372558 6da92788 4092 24 04373558 015c4e80 14 Free 25 04373568 6da92788 8172 26 04375558 015c4e80 14 Free 27 04375568 6da95c40 85012 28 29 Statistics: 30 MT Count TotalSize Class Name 31 015c4e80 6 80 Free 32 6da92788 4 17660 System.Object[] 33 6da95c40 1 85012 System.Byte[] 34 Total 11 objects