Hi, Can you explain why do you need to throw away the injectors after a given time ? How you handle singletons and provider injections after the injector swap ?
Thanks ! -- L On Fri, May 8, 2015 at 10:02 PM, <[email protected]> wrote: > Summary: > Issues with memory leaks when using multiple guice instances in succession > > Scenario: > > Bring up a guice container (instance1) and allow the application to run > with instance1, after some time bring up new guice container (guice2) and > if successful atomically switch the application to instance2. If instance2 > fails to start for any reason then keep using instance1. Once the switch > is complete then let guice1 be garbage collected. After the application > run for a while with intance2 restart the whole process and bring up > instance4, then instance5 ... > > Problem: > > Guice filter always contains a reference to any new guice instance. In > this case the guice filter is included in the guice container instance so > each time guice starts a new guice fitler gets created and used correctly > since the application determines which guice filter to submit the request > to. In the case that instance2 failed to start then instance2 should be > garbage collected and not stored in guice filter. > > Workaround: > > 1. use reflection to call GuiceFilter.reset This is a static method and > clears the unneeded reference. The guice filter still has reference to the > correct guice instance via the variable injectedPipeline > > Source code of workaround: > > Class guiceFilterClass = GuiceFilter.class; > Method[] methods = guiceFilterClass.getDeclaredMethods(); > for (Method method : methods) { > if (method.getName().equals("reset")) { > method.setAccessible(true); > method.invoke(null); > break; > } > } > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/google-guice. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-guice/d3c6677a-1488-4b22-9d98-d7c4e238c78f%40googlegroups.com > <https://groups.google.com/d/msgid/google-guice/d3c6677a-1488-4b22-9d98-d7c4e238c78f%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/CAD-udUCw9FZ9feCSy3rvVvZ2omeb7rOZ3gqvvBCN9Z-pz4hgoQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
