When using get() to checkout an object from the
org.apache.velocity.util.SimplePool, the reference remains in the SimplePool
and will only get released if the pool grows again to the peak level. The get
() operation could be easily modified to place a null value in the object
array location where the pooled item was removed so that if the object is not
returned to the pool (for whatever reason including exceptions), the reference
to the object does not remain in the pool until replaced in the stack-based
design of the SimplePool. It's just good pool management for a reusable class.
This became obvious when exceptions occured with the VelocityServlet
mergeTemplate() and objects were not returned to the pool. Memory profiling
showed references to VelocityWriter objects in the pool that were not released
until activity increased to replace the reference in the SimplePool object
array (and the memory could then be reclaimed).