Hi Sam,

the longest living of the child injectors live as long as a user session
lasts. With each session level chidl injector new entries for the (dynamic)
set of multi bound instances are added to the WeakKeySet of the root
injector we create using guice-servlet.

As you mentioned it would be good to get the entries GCed when the relevant
child injector is GC'd but since currently the Keys get directly
transformed into Strings before putting them in the blacklist, I guess this
would need a change there.

Since until I was mainly a user of Guice do you have a pointer where to
look in the internals to tackle a solution? I already tried some variants
with bascially backing the WeakKeySet with a Guava MapMaker with weak Key,
but that seems to be not yet sufficient there.

Regards,
Johannes


On Wed, Sep 25, 2013 at 3:46 PM, Sam Berlin <[email protected]> wrote:

> Do you keep each child injector live for a long time?  I wonder if a
> different approach where we attempt to clean up the WeakKeySet of GC'd Keys
> would be better or possible.
>
>  sam
>
>
> On Tue, Sep 24, 2013 at 4:16 PM, Johannes Wachter <
> [email protected]> wrote:
>
>> Hi Laszlo,
>>
>> yes using Session Scope consequently might be an option. But for some of
>> our use cases the current solution with child injectors per session would
>> still be an elegant choice, so it would be interesting if the problem with
>> multibindings and child injectors can be solved in some way. For example we
>> have through child injectors different configuration variants for the data
>> backend that get chosen depending on the user's actions and currently rely
>> on singleton bindings in a scope different than global or session.
>>
>> As an experimental change I today just removed the uniqueid from the
>> toString of the RealElement in guice-multibindings. For our use cases this
>> seems to solve the memory problems, but I'm not yet sure what possible side
>> effects this has since I didn't yet do further testing.
>>
>> Regards,
>> Johannes
>>
>> Am Sonntag, 22. September 2013 20:52:05 UTC+2 schrieb Laszlo Ferenczi:
>>>
>>> Hi Johannes,
>>>
>>> Maybe a silly question, but why not use SessionScope ? It was designed
>>> exactly for this use-case.
>>> (again, this suggestion is based on a very limited knowledge about the
>>> application or its requirements)
>>>
>>>
>>> --
>>> L
>>>
>>>
>>> On Sun, Sep 22, 2013 at 7:48 PM, Johannes Wachter <[email protected]
>>> > wrote:
>>>
>>>>  Hi,
>>>>
>>>> currently we're running into an issue with using Guice in our
>>>> application with using a combination of child injectors and multibindings.
>>>>
>>>> The issue is that we have a servlet based application that has one
>>>> global injector that spans the sessions. Each session has (at least) one
>>>> childinjector level to allow the relevant session level instances to be
>>>> directly bound. We are also using child injectors to bind session specific
>>>> sets of interface implementations in these child injectors.
>>>>
>>>> During a load test we found out, that this approach leads to each
>>>> session adding to the blacklist in the global injector, since each
>>>> multibinding in each session gets a new uniqueid. This lead to the global
>>>> blacklist filling up to around 500k entries which are never cleaned up.
>>>>
>>>> This seems to be the same issue as described here:
>>>> https://code.google.com/**p/google-guice/issues/detail?**id=756<https://code.google.com/p/google-guice/issues/detail?id=756>
>>>>
>>>> Is there any way to avoid this? Currently the only solution I would see
>>>> for it is extracting the multibindings to the top level and do possible
>>>> user specific filtering manually.
>>>>
>>>> Regards,
>>>> Johannes
>>>>
>>>> --
>>>> 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 google-guice...@**googlegroups.com.
>>>> To post to this group, send email to [email protected].
>>>>
>>>> Visit this group at 
>>>> http://groups.google.com/**group/google-guice<http://groups.google.com/group/google-guice>
>>>> .
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>
>>>
>>>  --
>> 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.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to