Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
4.1.6
-
None
-
None
Description
I think a found a resource leak in RegexpMatcher. It uses commons-pool
to cache the compiled regexps, with an eviction thread. The problem is that
nobody is calling close on the pool, so the eviction thread is always alive,
making the class loader not collectable. Here is the related code fragment:
public RegexpMatcher()
{ _pool = new GenericKeyedObjectPool(_factory); _pool.setMinEvictableIdleTimeMillis(EVICT_IDLE_TIME); _pool.setTimeBetweenEvictionRunsMillis(SLEEP_TIME); }(setMinEvictableIdleTimeMillis with a time different from -1 starts the eviction
thread).
No call is ever made to _pool.close(), and _pool is private.
I don't know what is the correct solution for this. One thing I can think of is
making _pool static, and expose a static close method on RegexpMatcher so that
it can be called on context shut down (does tapestry have a hook called on
context shut down?)
Andreas Andreou sugested that it's possible to have the services that instantiate
RegexpMatcher call a (new) close method on it whenever they're shutting down.
I found this tracking an out of perm gen error when redeploying a war for the 6th or 7th time
.