Hi, 
The pools implementation raises more questions:
1. The evictor thread starts running synchrnously, with same priority as thread which 
started it, and on single cpu machine , this will hamper the application performance.
2. The GenericKeyedObjectPool checks the "numTestsPerEvictionRun" of objects in each 
pass. how this number will be determined is tricky . First in keyedobjectpool, since 
it can hold many different object pools, there should be some facility to provide 
maxIdle for each pool. The evictor should determine if the number of objects in that 
pool are more than maxIdle for that pool and then based on timestamp delete the 
objects. Right now what happens is if GenericKeyedObjectPool has 3 Object pools , say 
for StringBuffer, Vector and Hashtable objects. The objective of pool is to maintain 
"some" quantity of eachof them , equivalent to lower threshold and each pool can grow  
upto max limit . in case where each object in pool is eligible for collection, what 
happens now is evictor will based on numofobjects_per_pass will can delete one whole 
pool but leave some other pools untouched. let me be more clear. say maxIdle = 300
and we have configured evictor thread to wake every 6 hours and check the pools. when 
evictor thread wakes up and determines the poolSize to be 500 it will start deleting 
object based on numberofobjectsto be investigated per pass. If we fix that to 200, 
what happens is StringBuffer object pool which had 50 objects to be pooled, Vector 150 
objects availble in idle pool and Hashtable 300 object available in object idle pool, 
the evictor thread in 200 runs totally finishes the 50 Stringobject  and most of 
vector objects  but barely touches the Hashtable pool. which defeats the purpose , 
because Hashtable has objects which are eligible for deletion, we need a basic min of 
StringBuffer and vector objects , this can be avoided if we the basic min threshhold 
is respected when deletion.
Secondly there is no way a user can determine the number of objects to be deleted in 
one pass ? at times traffic can be high , at times low , and deleting a fixed number 
of objects doesnt do anything. The numberofobjects to be deleted per pass should be 
some % of total idle pool size . 
3. The pool if used in web based applications , should make no gurantee that object 
borrowed should be returned, user can in middle of transaction  where server borrowed 
many objects can simple close browser and leave , leaving those borrowed objects in 
memory to be collected by jvm when session expires.

4. determining when evictor should run is again tough because it has same role as 
garbage collector in a way. when it starts , if pool size has million objects , and 
objects to be checked per pass are large , since the evictor  runs at same prirorty , 
on single cpu machines , this could have stop  the world type of behavior.



Rodney Waldhoff <[EMAIL PROTECTED]> wrote:

>The evict() method, and possibly others, can "garbage collect" pools
>from _poolMap and _poolList when they have no idle objects, so it is
>possible under "legal" circumstances for an object to be returned to an
>(internal) pool that no longer exists.
>
>It is also possible, using this behavior, to use the pool without an
>objectfactory, by populating the pool with a fixed number of objects at
>startup using returnObject.  A distinct method for this purpose may be
>more appropriate.
>
>On Mon, 11 Nov 2002 [EMAIL PROTECTED] wrote:
>
>> Hi i was checking the source for GenericKeyedObjectPool . In the method
>> returnObject check if a pool exists for the returned object and if
>> doesnt , we create one.If the object is borrowed using method
>> borrowObject(Object key) the code makes sure if there is no pool
>> associated with key , a new pool is created. So if object is "legally"
>> borrowed , the pool for the object will always exist when it is returned
>> back, where as if object was never borrowed at first place , there would
>> be no pool . So in my opinion return object should not create pool ,
>> else this would suffer from 2 ways
>>
>> 1. We create an entry in pool for that key and ask factory method to
>> destroy an object which was never created by it
>>
>> 2. the method loses its single purpose, kinda suffers from a multiple
>> personality disorder. please correct me if i am wrong ?
>>
>> here are the source lines
>>         CursorableLinkedList pool = null;
>>         synchronized(this) {
>>             pool = (CursorableLinkedList)(_poolMap.get(key));
>>             // if it doesn't exist, create it
>>             if(null == pool) {
>>                 pool = new CursorableLinkedList();
>>                 _poolMap.put(key, pool);
>>                 _poolList.add(key);
>>             }
>>         }
>>
>
>
>--
>To unsubscribe, e-mail:   <mailto:commons-user-unsubscribe@;jakarta.apache.org>
>For additional commands, e-mail: <mailto:commons-user-help@;jakarta.apache.org>
>
>

__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! 
http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/

Reply via email to