Hi:
Is there a way to know how many bytes were purged in last garbage cycle?

Signature
Ravi
rwallau@_RemoveThisTextAndUnderscores_springwireless.net
Naveen - 16 Jan 2006 21:40 GMT
Why would want to know? Is there any specific requirement? The
information can be obtained by using the CLR Hosting interface
ICLRGCManager::GetStats which returns
typedef struct _COR_GC_STATS {
ULONG Flags;
SIZE_T ExplicitGCCount;
SIZE_T GenCollectionsTaken[3];
SIZE_T CommittedKBytes;
SIZE_T ReservedKBytes;
SIZE_T Gen0HeapSizeKBytes;
SIZE_T Gen1HeapSizeKBytes;
SIZE_T Gen2HeapSizeKBytes;
SIZE_T LargeObjectHeapSizeKBytes;
SIZE_T KBytesPromotedFromGen0;
SIZE_T KBytesPromotedFromGen1;
} COR_GC_STATS;
Willy Denoyette [MVP] - 16 Jan 2006 22:49 GMT
You can get watch the Gen0, 1, 2 and large object heap sizes from the "CLR
memory" performance counters using perfmon, or from code by using the
System.Diagnostics.Performance class.
Willy.
| Hi:
| Is there a way to know how many bytes were purged in last garbage cycle?
Naveen - 16 Jan 2006 23:26 GMT
Can you know the bytes were purged in last garbage cycle using the
System.Diagnostics.Performance class?
Willy Denoyette [MVP] - 17 Jan 2006 10:27 GMT
| Can you know the bytes were purged in last garbage cycle using the
| System.Diagnostics.Performance class?
There is no exact counter for that, so you need to take snapshots at regular
intervals and compare the Gen0..2 collections counters and the Gen0..2
sizes. However it's not possible to say how much there has been collected
when the GC frequency is higher than the snapshot frequency. Note that the
CLR doesn't (for performance reasons)update the performance counters at each
GC run when the frequency exceeds a certain threshold.
Willy.
Ravi Ambros Wallau - 17 Jan 2006 12:19 GMT
I tried another approach and it did work for me, that's monitoring how many
bytes are allocated before and after the garbage collector cycle.
Thanks,
Ravi.
> Hi:
> Is there a way to know how many bytes were purged in last garbage
> cycle?