Skip to content

Commit 69de6dd

Browse files
noahfalktarekgh
andauthored
Root the System.Runtime EventSource (#108266)
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 (#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 #107919 once it is backported. Co-authored-by: Tarek Mahmoud Sayed <[email protected]>
1 parent c20bdf6 commit 69de6dd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSource.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public static class Keywords
2323
public const EventKeywords ProcessorCount = (EventKeywords)0x2;
2424
}
2525

26-
internal static RuntimeEventSource? Log => new RuntimeEventSource();
26+
// this roots the singleton instance of the event source
27+
internal static RuntimeEventSource Log { get; } = new RuntimeEventSource();
2728
private PollingCounter? _gcHeapSizeCounter;
2829
private IncrementingPollingCounter? _gen0GCCounter;
2930
private IncrementingPollingCounter? _gen1GCCounter;

0 commit comments

Comments
 (0)