Skip to content

Instantly share code, notes, and snippets.

chrisnas

Block or report user

Report or block chrisnas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View clearcollection.cs
private void ClearCollections(GCInfo info)
{
info.CurrentBGC = null;
info.GCInProgress = null;
}
View OnGcGlobalHeapHistory.cs
// 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");
View OnGcGlobalHeapHistory.cs
// 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");
View OnGcHeapStats.cs
// This event provides the size of each generation after the collection
// Note: last event for non background GC (will be GCGlobalHeapHistory for background gen 2)
private void OnGcHeapStats(EventWrittenEventArgs e)
{
var currentGC = GetCurrentGC(_gcInfo);
if (currentGC == null)
return;
currentGC.Heaps.Gen0Size = (long)GetFieldValue<ulong>(e, "GenerationSize0");
currentGC.Heaps.Gen1Size = (long)GetFieldValue<ulong>(e, "GenerationSize1");
View OnGcRestartEEEnd.cs
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
View OnGcSuspendEEBegin.cs
private void OnGcSuspendEEBegin(EventWrittenEventArgs e)
{
// we don't know yet what will be the next GC corresponding to this suspension
// so it is kept until next GCStart
_gcInfo.SuspensionStart = e.TimeStamp;
}
View SuspensionStartProperty.cs
// time when SuspendEEBegin is received for this process
// --> from here, all app threads will be suspended until RestartEEStop is received
// Note that we don't know yet what will be the triggered GC
public DateTime? SuspensionStart { get; set; }
View GetCurrentGC.cs
private GCDetails GetCurrentGC(GCInfo info)
{
if (info.GCInProgress != null)
{
return info.GCInProgress;
}
return info.CurrentBGC;
}
View OnGcStart.cs
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)
View HeapDetails.cs
public struct HeapDetails
{
public long Gen0Size { get; set; }
public long Gen1Size { get; set; }
public long Gen2Size { get; set; }
public long LOHSize { get; set; }
}
You can’t perform that action at this time.