Is there an existing issue for this?
Describe the bug
I am trying to create a multi tenant application, where each tenant has its own ServiceProvider and niddleware Pipleine (delegating some objects to a "root" ServiceProvider). A part of the design is being able to spin up and down "tenants" without restarting the host. I (think I) have it mostly sorted, but noticed a considerable memory leak when creating and disposing SerivceProviders and middleware pipelines:
The root cause is that the handle returned by ChangeToken.OnChange(...) in DefaultActionDescriptorCollectionProvider is silently dropped instead of disposed along with the DefaultActionDescriptorCollectionProvider. This effectively ties the lifetime of DefaultActionDescriptorCollectionProvider to the lifetime of the IWebHostEnvironment.WebRootFileProvider.
Expected Behavior
The handle returned by ChangeToken.OnChange should be disposed. ActionEndpointDataSourceBase already does this correctly. I have modeled my PR to match this implementation.
Making DefaultActionDescriptorCollectionProvider implement IDisposable will make it correctly disconnect from the file system watchers when the ServiceProvider is disposed.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
11.0.100-preview.4.26210.111
Anything else?
No response
Is there an existing issue for this?
Describe the bug
I am trying to create a multi tenant application, where each tenant has its own ServiceProvider and niddleware Pipleine (delegating some objects to a "root" ServiceProvider). A part of the design is being able to spin up and down "tenants" without restarting the host. I (think I) have it mostly sorted, but noticed a considerable memory leak when creating and disposing SerivceProviders and middleware pipelines:
The root cause is that the handle returned by
ChangeToken.OnChange(...)inDefaultActionDescriptorCollectionProvideris silently dropped instead of disposed along with theDefaultActionDescriptorCollectionProvider. This effectively ties the lifetime ofDefaultActionDescriptorCollectionProviderto the lifetime of theIWebHostEnvironment.WebRootFileProvider.Expected Behavior
The handle returned by ChangeToken.OnChange should be disposed.
ActionEndpointDataSourceBasealready does this correctly. I have modeled my PR to match this implementation.Making
DefaultActionDescriptorCollectionProviderimplementIDisposablewill make it correctly disconnect from the file system watchers when the ServiceProvider is disposed.Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
11.0.100-preview.4.26210.111
Anything else?
No response