[Blazor] IDisposable transient services are retained indefinitely #21652
Labels
area-blazor
Includes: Blazor, Razor Components
Docs
This issue tracks updating documentation
Done
This issue has been fixed
feature-blazor-wasm
This issue is related to and / or impacts Blazor WebAssembly
Milestone
REPO: https://github.com/mrpmorris/BlazorBug-21652
Any object that implements IDisposable is held onto by the dependency container. This means that if a class implements IDisposable and is registered as Transient, it will remain in the Blazor app scope forever.
Create a service.
Register it as a transient dependency.
Change Index.razor
The above code demonstrates that references are held until the user's session ends, causing a memory leak.
To prove the reproduction code is not responsible for holding on to the references, simply remove the IDisposable implementation and re-run.
The text was updated successfully, but these errors were encountered: