Skip to content

Instantly share code, notes, and snippets.

@chrisnas
Last active May 27, 2019 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisnas/47f93c05865a6a462743ef0bfe017a3c to your computer and use it in GitHub Desktop.
Save chrisnas/47f93c05865a6a462743ef0bfe017a3c to your computer and use it in GitHub Desktop.
private void OnGcStart(EventWrittenEventArgs e)
{
// This event is received after a collection is started
var newGC = BuildGCDetails(e);
// If a BCG is already started, FGC (0/1) are possible and will finish before the BGC
//
if (
(GetFieldValue<uint>(e, "Depth") == 2) &&
((GCType)GetFieldValue<uint>(e, "Type") == GCType.BackgroundGC)
)
{
_gcInfo.CurrentBGC = newGC;
}
else
{
_gcInfo.GCInProgress = newGC;
}
// forthcoming expected events for gen 0/1 collections are GCGlobalHeapHistory then GCHeapStats
}
private GCDetails BuildGCDetails(EventWrittenEventArgs e)
{
return new GCDetails()
{
Number = (int)GetFieldValue<uint>(e, "Count"),
Generation = (int)GetFieldValue<uint>(e, "Depth"),
Type = (GCType)GetFieldValue<uint>(e, "Type"),
Reason = (GCReason)GetFieldValue<uint>(e, "Reason")
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment