On Jul 31, 2008, at 6:20 PM, Artem Melentyev wrote:

> Vincent Massol wrote:
>> On Jul 29, 2008, at 11:10 PM, Artem Melentyev wrote:
>>
>>> Vincent Massol wrote:
>>>>
>>>> On Jul 29, 2008, at 8:52 PM, amelentev (SVN) wrote:
>>>>
>>>>> Author: amelentev
>>>>> Date: 2008-07-29 20:52:51 +0200 (Tue, 29 Jul 2008)
>>>>> New Revision: 11561
>>>>>
>>>>> Modified:
>>>>> platform/core/trunk/xwiki-core/src/main/resources/META-INF/plexus/
>>>>> components.xml
>>>>> Log:
>>>>> XWIKI-2444: QueryManager in Store
>>>>> set instantiation-strategy to per-lookup for prevent sharing of
>>>>> query objects.
>>>> We shouldn't do this IMO. Using a per lookup strategy with  
>>>> components
>>>> is very very dangerous (I've experienced it several times). The
>>>> problem is that you need to explicitely remove the components as
>>>> otherwise you're creating a memory leak.
>>> But how we should do instead?
>>> Queries are not reuseable.
>>> So we can't use Queries as components?
>>
>> Plexus keeps an internal reference to these per lookup components so
>> they're not released automatically.
>>
>> Personally I've been trying to stay away from per lookup component  
>> and
>> use only POJOs.
>>
>> I'm fine if you want to keep it as a component but you *must* be
>> absolutely sure that you release them using componentManager.remove()
>> when they're not used anymore.
>
> Where we should release it? after Query#execute ?

It's the code using the query that must release it as soon as it's not  
longer using it.

> This is also potential memory leak  if someone forget to run #execute
> for some query.

That's why I'd prefer if we can use a POJO instead.

> Can we release them just after they created? (in  
> QueryManager#createQuery)
> This looks wrong, but works fine.

This definitely looks wrong!

> Can we configure component manager for not to store ref?

Not AFAIK. You could ask on the plexus list though.

Thanks
-Vincent

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to