|
|
CommonsPoolTargetSource initializating beans that are not added to the pool
I configure a pool to have minIdle of x, but 2x beans are initialized.
This would not be an issue if all of these items were added to the pool but half of them seem to neither be added or destroyed.
I am not sure if this is an issue with the GenericObjectPool, my usage, or CommonsPoolTargetSource but searching has so far been futile.
My configuration is: lt;bean id=quot;targetquot; class=quot;com...quot; scope=quot;prototypequot; lazy-init=quot;falsequot; init-method=quot;initializeEnginequot; destroy-method=quot;destroyquot;gt;
... lt;/beangt;
lt;bean id=quot;targetSourcequot; scope=quot;singletonquot; class=quot;org..aop.target.CommonsPoolT argetSourcequot; lazy-init=quot;falsequot; init-method=quot;createObjectPoolquot;gt; lt;property name=quot;targetBeanNamequot; value=quot;targetquot;/gt; lt;property name=quot;maxSizequot; value=quot;5quot;/gt; lt;property name=quot;minIdlequot; value=quot;3quot;/gt; lt;property name=quot;maxIdlequot; value=quot;4quot;/gt; lt;property name=quot;timeBetweenEvictionRunsMillisquot; value=quot;2000quot;/gt; lt;/beangt;
The above configuration results in:
6 calls to my initialize method
0 calls the destruction method
a pool with 3 idle objects before any are borrowed
My main worry is that I have configured things incorrectly as I would expect the extra three beans to have been destroyed (they take large amounts of memory). I am worried that if this code is used I will end up never destroying my target beans.
I am also concerned that about the three wasted initializations (they each can take up to a minute). Though this is more of a point of curiosity than concern at this point.
Thanks in advance for any ideas you may have.
Apparently I was creating two pools as a result of the targetSource's init-method being set to createObjectPool |
|