Re: [xwiki-devs] [xwiki-notifications] r11561 - platform/core/trunk/xwiki-core/src/main/resources/META-INF/plexus
Hi Artem, 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. Thanks -Vincent > Modified: platform/core/trunk/xwiki-core/src/main/resources/META-INF/ > plexus/components.xml > =================================================================== > --- platform/core/trunk/xwiki-core/src/main/resources/META-INF/ > plexus/components.xml 2008-07-29 17:38:19 UTC (rev 11560) > +++ platform/core/trunk/xwiki-core/src/main/resources/META-INF/ > plexus/components.xml 2008-07-29 18:52:51 UTC (rev 11561) > @@ -52,6 +52,7 @@ > <role>com.xpn.xwiki.store.query.Query</role> > <role-hint>hql</role-hint> > <implementation>com.xpn.xwiki.store.hibernate.query.HqlQuery</ > implementation> > + <instantiation-strategy>per-lookup</instantiation-strategy> > <requirements> > <requirement> > <role>org.xwiki.context.Execution</role> > @@ -62,6 +63,7 @@ > <role>com.xpn.xwiki.store.query.Query</role> > <role-hint>hibernateNamed</role-hint> > > < > implementation > >com.xpn.xwiki.store.hibernate.query.HibernateNamedQuery</ > implementation> > + <instantiation-strategy>per-lookup</instantiation-strategy> > <requirements> > <requirement> > <role>org.xwiki.context.Execution</role>
Vincent Massol wrote:
Hi Artem,
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? -- Artem Melentyev
On Jul 29, 2008, at 11:10 PM, Artem Melentyev wrote:
Vincent Massol wrote:
Hi Artem,
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. Thanks -Vincent
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 ? This is also potential memory leak if someone forget to run #execute for some query. Can we release them just after they created? (in QueryManager#createQuery) This looks wrong, but works fine. Can we configure component manager for not to store ref? -- Artem Melentyev
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
participants (2)
-
Artem Melentyev -
Vincent Massol