1

无论如何,是否可以从转储文件中获取有关为不同代执行了多少垃圾收集的信息。当我尝试运行一些 psscor4 命令时,我得到了关注。

0:003> !GCUsage
The garbage collector data structures are not in a valid state for traversal.
It is either in the "plan phase," where objects are being moved around, or
we are at the initialization or shutdown of the gc heap. Commands related to 
displaying, finding or traversing objects as well as gc heap segments may not 
work properly. !dumpheap and !verifyheap may incorrectly complain of heap 
consistency errors.
Error: Requesting GC Heap data
0:003> !CLRUsage
The garbage collector data structures are not in a valid state for traversal.
It is either in the "plan phase," where objects are being moved around, or
we are at the initialization or shutdown of the gc heap. Commands related to 
displaying, finding or traversing objects as well as gc heap segments may not 
work properly. !dumpheap and !verifyheap may incorrectly complain of heap 
consistency errors.
Error: Requesting GC Heap data

虽然我可以从 eehpeap 获得输出,但它并没有给我我想要的东西。

0:003> !EEHeap -gc
Number of GC Heaps: 1
generation 0 starts at 0x0000000002c81030
generation 1 starts at 0x0000000002c81018
generation 2 starts at 0x0000000002c81000
ephemeral segment allocation context: none
 segment     begin allocated  size
0000000002c80000  0000000002c81000  0000000002c87fe8  0x6fe8(28648)
Large object heap starts at 0x0000000012c81000
 segment     begin allocated  size
0000000012c80000  0000000012c81000  0000000012c9e358  0x1d358(119640)
Total Size:              Size: 0x24340 (148288) bytes.
------------------------------
GC Heap Size:            Size: 0x24340 (148288) bytes.
4

1 回答 1

1

转储

您可以在性能监视器中看到垃圾收集的数量。然而,性能计数器的工作方式让我相信这些信息在转储文件中不可用,甚至可能在实时调试期间不可用。

想想Debug.WriteLine():一旦文本被写入调试输出,它就消失了。如果您当时没有运行DebugView,则信息会丢失。这很好,否则它看起来像内存泄漏。

性能计数器(据我了解)以类似的方式工作。发送各种“ping”以供其他人(性能监视器)进行记录。如果没有人这样做,那么包含所有信息的 ping 都将消失。

实时调试

如前所述,您可以尝试性能监视器。如果您更喜欢 WinDbg,您可以使用它sxe clrn来查看垃圾收集的发生情况。

PSSCOR

您提到的命令不显示有关垃圾收集计数的信息:

0:016> !gcusage
Number of GC Heaps: 1
------------------------------
GC Heap Size          0x36d498(3,593,368)
Total Commit Size  0000000000384000 (3 MB)
Total Reserved Size  0000000017c7c000 (380 MB)

0:016> !clrusage
Number of GC Heaps: 1
------------------------------
GC Heap Size          0x36d498(3,593,368)
Total Commit Size  0000000000384000 (3 MB)
Total Reserved Size  0000000017c7c000 (380 MB)

注意:我在这里使用 PSSCOR2,因为我在这台机器上有相同的 .NET 4.5 问题。但我希望 PSSCOR4 的输出是相似的。

于 2014-09-22T20:40:02.827 回答