Ali Tarhini
Ali Tarhini

Reputation: 5358

how to profile .net garbage collector?

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.

Upvotes: 5

Views: 2681

Answers (3)

Eric Falsken
Eric Falsken

Reputation: 4934

Check out JetBrains DotTrace.

Upvotes: 1

Steve Townsend
Steve Townsend

Reputation: 54148

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.

Upvotes: 5

Ta01
Ta01

Reputation: 31610

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.

Upvotes: 1

Related Questions