Skip to content

Instantly share code, notes, and snippets.

@chrisnas
Created May 27, 2019 11:58
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/5637fa18c0ed749505b45b7c7e8776dc to your computer and use it in GitHub Desktop.
Save chrisnas/5637fa18c0ed749505b45b7c7e8776dc to your computer and use it in GitHub Desktop.
private void OnGcRestartEEEnd(EventWrittenEventArgs e)
{
var currentGC = GetCurrentGC(_gcInfo);
if (currentGC == null)
{
// this should never happen, except if we are unlucky to have missed a GCStart event
return;
}
// compute suspension time
double suspensionDuration = 0;
if (_gcInfo.SuspensionStart.HasValue)
{
suspensionDuration = (e.TimeStamp - _gcInfo.SuspensionStart.Value).TotalMilliseconds;
_gcInfo.SuspensionStart = null;
}
else
{
// bad luck: a xxxBegin event has been missed
}
currentGC.PauseDuration += suspensionDuration;
// could be the end of a gen0/gen1 or of a non concurrent gen2 GC
if (
(currentGC.Generation < 2) ||
(currentGC.Type == GCType.NonConcurrentGC)
)
{
GcEvents?.Invoke(this, BuildGcArgs(currentGC));
_gcInfo.GCInProgress = null;
return;
}
// in case of background gen2, just need to sum the suspension time
// --> its end will be detected during GcGlobalHistory event
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment