Skip to content

Question about garbage collector #56

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

Closed
TheVinhLuong opened this issue Mar 18, 2020 · 5 comments
Closed

Question about garbage collector #56

TheVinhLuong opened this issue Mar 18, 2020 · 5 comments

Comments

@TheVinhLuong
Copy link

Are instances returned by a factory eligible for garbage collection? And how about singleton?

@escamoteur
Copy link
Collaborator

GetIt doeesn't keep any referenes to Objects created by Factories.

It has to keep references to Singletons to be able to access them though. Howver you can dispose them manually. By calling unregister you can free a Singleton and even pass a disposing function.

@kmartins
Copy link
Contributor

@escamoteur The resetLazySingleton works the same that unregister discarding the Singleton?

@escamoteur
Copy link
Collaborator

yep, reset also frees the existing instance

@kmartins
Copy link
Contributor

Ok, so in the question of performance, I can use registerLazySingleton with resetLazySingleton without problems? Or it would be better always use unregister?

@escamoteur
Copy link
Collaborator

with LazySingletons you can always just use reset unless you want to remove the registrataion which would lead to an exception on the next access if you don't reregister it. Performance difference is not the point.

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

3 participants