When we are no more referencing a google guice injector in the application, when will be the resources held by the injector, like Singletons, released or garbage collected?
To illustrated more, consider this code snippet:
public void someFunction() {
Injector injector = Guice.createInjector(new DataStoreBindings());
DataTransactor transactor =
injector.getInstance(DataInfoTransactor.class);
transactor.doSomething();
}Some singleton bindings are also created by this injector. When this function ends the Injector instance will go out of scope and application has no way to refer this Injector again.
I want to know, if the injector will be garbage collected? If yes, then what will happen to the singletons held by the injector?