I looked a little more carefully and it seems that things are much worse than I thought. These are more like "phantom" binding errors. Guice is apparently doing some analysis at injector creation time--it's pre-constructing and storing in memory what appears to be all potential binding errors, even if the errors don't actually exist in the code.
For instance, there is a binding error stored in memory in the event that an object is requested that was bound but not exposed in a private module (robot legs). Of course, that's the whole purpose of private modules. I assume Guice does this because once the injector is created, it never wants to look at the modules again, but needs to have the error available in case someone tries to access a private unexposed object? I guess it ends up that I don't want a strict error checking mode, I actually want a "release mode" or something, where Guice doesn't construct these "errors"! I'm not sure if this would even be possible, but better yet would be to fix Guice so that upon binding error, it could recreate the injector (re-parsing the modules, etc.) to find the cause of the error. On Tuesday, July 24, 2012 2:05:08 PM UTC-5, glenviewjeff wrote: > > I started doing a memory analysis of my Android app and was quite > surprised to find that in memory there were a bunch of Java strings holding > binding errors inside a child injector. These errors are apparently not > reported upon injector creation. I wrote unit tests for the erroneous > bindings and as expected, they caused a runtime binding error. > > It looks like the errors are stored in memory after constructing the > injector but only thrown when a client object requests that the erroneous > object is be injected. My integration tests somehow didn't pick up these > binding errors and the errors are wasting significant runtime memory. > > Running and poking around through memory dumps is not a terribly feasible > way to find these. Is there a strict error checking/reporting feature for > Guice to give me the information on all broken bindings at the time the > injector is created? Is there a reason this isn't the default behavior? > > > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-guice/-/SH0BfcTZ6zYJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
