Open benaadams opened 2 months ago
Tagging subscribers to this area: @mangod9 See info in area-owners.md if you want to be subscribed.
Tagging subscribers to this area: @dotnet/gc See info in area-owners.md if you want to be subscribed.
The thread-local field might not be the only thing that refers to the same instance. In that case, it would be wrong to automatically dispose or finalize the referenced instance when the thread exits, unless the thread-local field is opted in somehow. (Perhaps a new bool DisposeValueOnThreadExit
property on ThreadStaticAttribute
and ThreadLocal<T>
; the IDisposable.Dispose implementation could then call GC.SuppressFinalize.)
Tagging subscribers to this area: @mangod9 See info in area-owners.md if you want to be subscribed.
Adding @davidwrighton who has been doing work in this area.
When a thread exits; all its thread locals end up on the finalization queue (perhaps unsurprisingly)
However the runtime is controling when threads are exited; would it be possible it instead dispose all these locals as part of the thread exit so they don't all end up on the finalization queue?