You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A special lifetime manager creates singletons within hierarchies. It would return the same object as long as resolution is happening at the same hierarch level. If resolved in a child container, a new object would be created.
Problem
When object is resolved in one of the child containers, the manager creates and maintains a strong reference to that container. It is used later to identify a value associated with that scope.
If the child container is properly discarded, when it is no longer needed, by calling IDisposable.Dispose(), the manager releases the reference and scope is collected by GC.
If the child container is released without being disposed, the manager has no way of knowing that it is no longer alive and would
still keep the reference preventing the scope from being collected.
This behavior could potentially contribute to a memory leaks and performance degradation.
Solution
Instead of using ConcurrentDictionary for storing references to the scopes a custom solution utilizing Weak References should be implemented.
The text was updated successfully, but these errors were encountered:
HierarchicalLifetimeManager
A special lifetime manager creates singletons within hierarchies. It would return the same object as long as resolution is happening at the same hierarch level. If resolved in a child container, a new object would be created.
Problem
When object is resolved in one of the child containers, the manager creates and maintains a strong reference to that container. It is used later to identify a value associated with that scope.
If the child container is properly discarded, when it is no longer needed, by calling
IDisposable.Dispose()
, the manager releases the reference and scope is collected by GC.If the child container is released without being disposed, the manager has no way of knowing that it is no longer alive and would
still keep the reference preventing the scope from being collected.
This behavior could potentially contribute to a memory leaks and performance degradation.
Solution
Instead of using
ConcurrentDictionary
for storing references to the scopes a custom solution utilizingWeak References
should be implemented.The text was updated successfully, but these errors were encountered: