Skip to content
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

Add WeakReferenceLifetimeManager #2

Open
ENikS opened this issue May 9, 2019 · 0 comments
Open

Add WeakReferenceLifetimeManager #2

ENikS opened this issue May 9, 2019 · 0 comments
Assignees

Comments

@ENikS
Copy link
Contributor

ENikS commented May 9, 2019

Description

At present ExternallyControlledLifetimeManager is being used as a weak reference lifetime manager. It is allowed to be used in all types of registrations.

Problem

If a Type or Factory are registered with ExternallyControlledLifetimeManager it works like this:

  • No instance is present: create a new one and hold a weak reference
  • Instance is still alive: return the instance
  • Instance went out of scope: create a new instance

In case of externally registered instance the container has no knowledge of how to create a new instance. This break the logic above.

The solution to this problem is to reserve ExternallyControlledLifetimeManager to be registered only with external instances and keep strong reference to these to prevent it from being collected by GC.

@ENikS ENikS self-assigned this May 9, 2019
@ENikS ENikS reopened this May 15, 2019
@ENikS ENikS transferred this issue from unitycontainer/abstractions May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant