I'd like to know how to profile the performance of the garbage collector and monitor the three generations. I wonder if it is possible to know at any point in time what are the current objects living in gen0,gen1,gen2
.
问题:
回答1:
You can get useful information on GC performance from PerfMon - not as granular as you want though.
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.
If you have one of the premium versions of Visual Studio that includes Performance/Profiling Tools, you can get more info on individual object allocations and lifetimes. Specifically, this might be in the area you wished:
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.
If you are feeling really adventurous, you can do custom profiling using the Profiling Tools API.
回答2:
The CLR profiler could do this, but I don't think it is actively updated i.e for 3.5, 4.0, for 2.0 targeted apps, you can do this with the linked version.
回答3:
Check out JetBrains DotTrace.