RE: [coldbox:8490] Re: WireBox notes

Ok, I’ve got you. Even though the injector that the provider references is dead, it is able to find the current one.
So, at first the original injector is just returning itself, but after a reinit, it is finding its replacement.

I’ll concede that will work but I’m not done yet :slight_smile:

I’m still going to argue against keeping a hard reference to the injector on the grounds that reinitting your app over a period of time will create a potential memory leak.
The injector is not an island. It also has references to it’s binder, LogBox, CacheBox, and potentially the ColdBox controller.
If I have persisted a provider in application, not only will that keep the original injector from going out of scope, but I believe it will also prevent all objects that the injector references from going out of scope as well.

So the potential payload could go like so:

→ App inits with injector a, logbox a, cachebox a, and controller a (etc…)
→ Persist model 1 in application with a provider that references the a’s
→ Reinit app which creates injector b, logbox b, cachebox b, and controller b
→ Persist model 2 in application with a provider that references the b’s

→ Reinit app which creates injector c, logbox c, cachebox c, and controller c

→ Persist model 3 in application with a provider that references the c’s

At this point in time, injector a, injector b, and injector c will all return injector c when asked for their scoped self (which means “it works”)

However, injector a, logbox a, cachebox a, controller a, injector b, logbox b, cachebox b, and controller b will still be bound in memory and unable to be garbage collected due to their GC roots via the providers.

You will essentially be keeping all previous instances of the ColdBox framework and all it’s aspects in memory as long as their is a persisted model that has a provider referencing them.

If you like, I can fire up JRockit Mission control and do some heap inspection while running a few tests to confirm how this may impact garbage collection and therefore memory usage.

Thoughts?

~Brad