@ Override final void periodicDrain ( ) { // Drain to the minimum size but only by the maxDrainAmount. // This slows the drain process, allowing for the pool to become // active before becoming fully drained (to minimum level). SizeData size = poolSize ; int numDiscarded = drainToSize ( size . minSize , size . maxDrainAmount ) ; // When a pool becomes inactive, and is drained to the minimum level // then there is really no point to continue calling periodicDrain. // To avoid this, the pool is removed from the list of managed pools, // and since the pool has a reference to the pool manager, it can // easily add itself back to the list if it becomes active again. // Note that this has the side effect of allowing orphaned pools // to be garbage collected... since the PoolManager will also drop // its reference. d376426 if ( numDiscarded == 0 ) { // Do not remove immediately, but keep a count and only // remove after a few iterations of no drain... to avoid // some of the churn of add/remove for pools that are // used regularly, but lightly. ++ ivInactiveNoDrainCount ; if ( ivInactiveNoDrainCount > 4 ) { synchronized ( this ) { poolMgr . remove ( this ) ; ivManaged = false ; } // Reset the count for the next time it becomes active. ivInactiveNoDrainCount = 0 ; } } else ivInactiveNoDrainCount = 0 ; }
Remove a percentage of the elements from this pool down to its minimum value . If the pool becomes active while draining discontinue .