A memory leak occurs when undeploying/redeploying a webapp that uses Commons Logging. How do I fix this?
When commons-logging is deployed in a “shared” classloader that is visible to all webapps, commons-logging still ensures that each webapp gets its own logging configuration by setting up a separate LogFactory object for each context classloader, and ensuring that the correct LogFactory object is used based on the context classloader set whenever LogFactory.getLog is called. However the negative side of this is that LogFactory needs to keep a static map of LogFactory objects keyed by context classloader; when the webapp is “undeployed” this means there is still a reference to the undeployed classloader preventing the memory used by all its classes from being reclaimed. The commons-logging-optional.jar optional code provided with commons-logging 1.0.5 attempted to address this issue using weak references, but this approach cannot solve the issue in many cases.