我正在尝试调查我的应用程序的内存问题。这是 .NET 堆大小。
0:000> !EEHeap -gc
Number of GC Heaps: 4
------------------------------
Heap 0 (000000000111f740)
generation 0 starts at 0x000000019eb31750
generation 1 starts at 0x000000019e41f328
generation 2 starts at 0x0000000180091000
ephemeral segment allocation context: (0x000000019eb31750, 0x000000019eb31768)
segment begin allocated size
0000000180090000 0000000180091000 00000001a4591d38 0x24500d38(609226040)
Large object heap starts at 0x0000000580091000
segment begin allocated size
0000000580090000 0000000580091000 0000000580e3e868 0xdad868(14342248)
Heap Size: Size: 0x252ae5a0 (623568288) bytes.
------------------------------
Heap 1 (000000000112afd0)
generation 0 starts at 0x000000029df85cb8
generation 1 starts at 0x000000029d7e5d78
generation 2 starts at 0x0000000280091000
ephemeral segment allocation context: (0x000000029df85cb8, 0x000000029df85cd0)
segment begin allocated size
0000000280090000 0000000280091000 00000002a54d7f40 0x25446f40(625241920)
Large object heap starts at 0x0000000590091000
segment begin allocated size
0000000590090000 0000000590091000 00000005927a0a90 0x270fa90(40958608)
Heap Size: Size: 0x27b569d0 (666200528) bytes.
------------------------------
Heap 2 (0000000001137180)
generation 0 starts at 0x000000039d8552c0
generation 1 starts at 0x000000039d006788
generation 2 starts at 0x0000000380091000
ephemeral segment allocation context: (0x000000039d8552c0, 0x000000039d8552d8)
segment begin allocated size
0000000380090000 0000000380091000 00000003a483c878 0x247ab878(612022392)
Large object heap starts at 0x00000005a0091000
segment begin allocated size
00000005a0090000 00000005a0091000 00000005a12444f8 0x11b34f8(18560248)
Heap Size: Size: 0x2595ed70 (630582640) bytes.
------------------------------
Heap 3 (0000000001144530)
generation 0 starts at 0x000000049ea19638
generation 1 starts at 0x000000049e1cfbb0
generation 2 starts at 0x0000000480091000
ephemeral segment allocation context: (0x000000049ea19638, 0x000000049ea19650)
segment begin allocated size
0000000480090000 0000000480091000 00000004a4969bb8 0x248d8bb8(613256120)
Large object heap starts at 0x00000005b0091000
segment begin allocated size
00000005b0090000 00000005b0091000 00000005b08a0e90 0x80fe90(8453776)
Heap Size: Size: 0x250e8a48 (621709896) bytes.
------------------------------
GC Heap Size: Size: 0x9784c728 (2542061352) bytes.
当我运行 perfView 时,它显示 AsyncPinned 句柄占用了大部分内存,如下所示。
这就是 !Gchandles 所展示的。
Handles:
Strong Handles: 7653
Pinned Handles: 16
Async Pinned Handles: 1183
Weak Long Handles: 2412
Weak Short Handles: 918
Dependent Handles: 2
我对 AsyncPinned 句柄了解不多,但我怎么知道哪些对象正在创建这些句柄,谁在阻止这些句柄,为什么这些没有得到清理?
编辑 我已经阅读了为此重复的链接,但我试图找出如何知道这些 AsyncPinned 句柄是在哪里创建的,该链接中没有解释