-
-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CopyOnWriteRegistry possibly not correctly disposed #746
Comments
This gets a little complicated, but I think you might be right. Some research/notes: The only place we create The While the parent lifetime scope (or container) is responsible for disposing of the root component registry, the creation of these disposable scope restricted registries doesn't actually appear to get handled - the That said, it doesn't look like anything actually ever does dispose of these What it looks to me needs to happen:
@alexmg Does this sound right to you? |
When a child scope is created, along with its registry, we need to keep track of what needs to be disposed of later. The registry is part of those things. The registry passed in the constructor doesn't always fall in that category (think root scope), and hence the registry is added in the BeginLifetimeScope methods. Issue autofac#746
When the registry hasn't been touched, nothing needs to be disposed. Only when the registry has been modified, and hence a new (write) registry allocated, should the registry be disposed. This is determined by the _writeRegistry field being non-null. Issue autofac#746
When the registry hasn't been touched, nothing needs to be disposed. Only when the registry has been modified, and hence a new (write) registry allocated, should the registry be disposed. This is determined by the _writeRegistry field being non-null. Fixes Resharper warnings in that class. Issue autofac#746
When a child scope is created, along with its registry, we need to keep track of what needs to be disposed of later. The registry is part of those things. The registry passed in the constructor doesn't always fall in that category (think root scope), and hence the registry is added in the BeginLifetimeScope methods. Issue autofac#746
Fixed #746: Registrations added to a nested lifetime scope were not being disposed.
This fix is included in 4.6.1 which has been pushed to NuGet. |
at: Autofac/src/Autofac/Core/Registration/CopyOnWriteRegistry.cs line:59
_readRegistry?.Dispose();
Whether it should be:
_writeRegistry?.Dispose();
this code will not throw an exception,Since you did not call _componentRegistry.Dispose() in LifetimeScope.Dispose()
The text was updated successfully, but these errors were encountered: