Created
May 27, 2019 12:07
-
-
Save chrisnas/7a203f0621dbd039c0b09a66af974ee5 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
// This event is used to figure out if a collection is compacting or not | |
// Note: last event for background GC (will be GCHeapStats for ephemeral (0/1) and non concurrent gen 2 collections) | |
private void OnGcGlobalHeapHistory(EventWrittenEventArgs e) | |
{ | |
var currentGC = GetCurrentGC(_gcInfo); | |
// check unexpected event (we should have received a GCStart first) | |
if (currentGC == null) | |
return; | |
var globalMask = GetFieldValue<GCGlobalMechanisms>(e, "GlobalMechanisms"); | |
currentGC.IsCompacting = | |
(globalMask & GCGlobalMechanisms.Compaction) == GCGlobalMechanisms.Compaction; | |
// this is the last event for gen 2 background collections | |
if ((GetFieldValue<int>(e, "CondemnedGeneration") == 2) && (currentGC.Type == GCType.BackgroundGC)) | |
{ | |
// check unexpected generation mismatch | |
var globalMask = (GCGlobalMechanisms)GetFieldValue<uint>(e, "GlobalMechanisms"); | |
currentGC.IsCompacting = | |
(globalMask & GCGlobalMechanisms.Compaction) == GCGlobalMechanisms.Compaction; | |
// this is the last event for gen 2 background collections | |
if ((GetFieldValue<uint>(e, "CondemnedGeneration") == 2) && (currentGC.Type == GCType.BackgroundGC)) | |
{ | |
GcEvents?.Invoke(this, BuildGcArgs(currentGC)); | |
ClearCollections(_gcInfo); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment