David Graham wrote:
Using a WeakHashMap might be a good solution. Connections are

guaranteed


to be closed when they are garbage collected so if a client doesn't

return


a connection and loses all pointers to it, the pool would lose its
reference to it and the Connection would get gc'd.  This is *much*

better


than grabbing a connection away from the client application that may

still


be using it.


Using a weak reference for pooled connections which are in use is a good idea and I am all for it.

The only problem is that there is no guarantee when the weak referenced
db connection pool object will be GC'd.  That is highly dependent upon
how the JVM implements GC.  There is no guarantee that this would
prevent
abandoned connections from causing the pool to be exhausted.



That's a valid point but unlikely to happen in a highly loaded server JVM
that's creating and destroying many objects.  I think it's sufficient to
say that the pool won't hold onto connections that apps have lost but it's
up to the apps not to lose them in the first place.



It depends on which generation the connection pool object ends up in.
In this case connection pool objects would end up in the GC generation
which is least often swept for GC.  Most likely these objects would only
get GC'd during a Full GC. Full GC's can happen very infrequently, even
on a heavily loaded server if the JVM is tuned right.

Glenn

----------------------------------------------------------------------
Glenn Nielsen             [EMAIL PROTECTED] | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to