Skip to content

Commit

Permalink
Root the System.Runtime EventSource (dotnet#108266)
Browse files Browse the repository at this point in the history
Root the System.Runtime EventSource

The System.Runtime EventSource (RuntimeEventSource), was unintentionally being garbage collected because it wasn't rooted. This caused runtime EventCounters to no longer be available after GC occurred.

This was a regression from a recent change (dotnet#106014). That change accidentally converted the static field that was intended to the root the object into a property getter that returned a new instance each time it was called. This fix converts the property back to being initialized only once.

This will fix dotnet#107919 once it is backported.

Co-authored-by: Tarek Mahmoud Sayed <10833894+tarekgh@users.noreply.github.com>
  • Loading branch information
2 people authored and sirntar committed Sep 30, 2024
1 parent bc62efc commit d6e3aa6
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public static class Keywords
public const EventKeywords ProcessorCount = (EventKeywords)0x2;
}

internal static RuntimeEventSource? Log => new RuntimeEventSource();
// this roots the singleton instance of the event source
internal static RuntimeEventSource Log { get; } = new RuntimeEventSource();
private PollingCounter? _gcHeapSizeCounter;
private IncrementingPollingCounter? _gen0GCCounter;
private IncrementingPollingCounter? _gen1GCCounter;
Expand Down

0 comments on commit d6e3aa6

Please sign in to comment.