无论如何都要获取有关从转储文件中为不同代生成了多少垃圾收集的信息。当我尝试运行一些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.
答案 0 :(得分:1)
您可以在性能监视器中查看垃圾收集的数量。但是,性能计数器的工作方式使我相信这些信息在转储文件中不可用,甚至可能在实时调试期间不可用。
想想Debug.WriteLine()
:一旦文本被写入调试输出,它就消失了。如果您当时没有DebugView运行,则信息会丢失。这很好,否则看起来就像是内存泄漏。
性能计数器(据我所知)以类似的方式工作。各种各样的" ping"被发送给其他人(性能监视器)进行记录。如果没有,ping及其所有信息都将消失。
如前所述,您可以尝试使用性能监视器。如果您更喜欢WinDbg,可以使用sxe clrn
来查看垃圾收集。
您提到的命令不显示有关垃圾收集计数的信息:
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,因为我在这台机器上有the same .NET 4.5 issue。但我希望PSSCOR4的输出类似。