我想知道如何分析垃圾收集器的性能并监控三代。我想知道是否可以在任何时间点知道 gen0,gen1,gen2
中当前存在的对象是什么。
最佳答案
您可以获得useful information on GC performance from PerfMon - 但没有你想要的那么精细。
There are many .NET Memory Performance Counters and this is meant to give you some guidelines in interpreting the counter data and how to correlate them. This assumes you have a basic understanding of GC.
如果您拥有包含 Performance/Profiling Tools 的 Visual Studio 高级版本之一,您可以获得有关单个对象分配和生命周期的更多信息。具体来说,这可能位于您想要的区域:
The garbage collector reclaims memory by deallocating a whole generation of objects. For objects that the profiled application created, the Object Lifetime view displays the number and size of the objects and the generation when they are reclaimed.
如果您真的喜欢冒险,您可以使用 Profiling Tools API 进行自定义分析。 .
关于.net - 如何分析 .net 垃圾收集器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4288898/