Last active
May 27, 2019 11:51
-
-
Save chrisnas/47f93c05865a6a462743ef0bfe017a3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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