You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Vikram Goyal <V....@cbit.uq.edu.au> on 2004/05/05 03:42:48 UTC

[POOL] Initial Pool size

Hello,

 

My query regarding the initial size of a pool seems so basic that I am
sure that I am wasting your time. However, I have scoured the source
code for both Pool and DBCP for the better part of a day and I am having
trouble understanding how the initial size of a pool is maintained. I
apologize in advance if the answer should be right in front of my eyes
and I can't see it.

 

At the moment, as I understand it, the only way to set the initial size
of a pool is by the following code:

 

pool.setMinIdle(5); // some random number

pool.setTimeBetweenEvictionRunsMillis(200L); // basically set to a
non-negative value

 

As per the documentation and the code, the pool will only be initialized
with the min idle value of 5 as specified above IF an Evictor thread is
started. This can only happen by overriding the default value of -1 for
"time between eviction runs millis" property of the pool.

 

Is this assumption correct? Technically, this means that, with the
default settings in place, no objects are present in the initial pool,
as minIdle is set to 0 and the eviction thread is not started because it
is only started for non-negative values of the above property.  With
these default settings, it also means that objects are added to the
pool, only when they are requested the first time. This solves the
purpose of reusability, provided the borrowed objects are returned, it
gives slower response time for initial objects.

 

This seems to me an odd way of initializing the pool. Why would you want
the Evictor thread to initialize the pool as a side effect of its main
work of evicting idle objects? Shouldn't the pool initialize itself
based on an initial pool size property?

 

Regards,

Vikram