Application with log4j causes perm gen leak across redeployments
Environment
- JBoss Enterprise Application Platform (EAP)
- log4j
Issue
- Our application has log4j bundled in it. After redeploying this app several times, we hit a perm gen OOME. The heap dump shows many of the application classloaders persisted by a still running log4j PropertyWatchdog or FileWatchdog thread.
Resolution
- The thread would be started due to a call to Content from logging.apache.org is not included.
PropertyConfigurator.configureAndWatchso its use should be avoided. Just call configure instead. - If using Spring, do not set the
log4jRefreshIntervalparameter
Root Cause
- log4j does not offer a way to shutdown PropertyWatchdog or FileWatchdog threads
- Content from bz.apache.org is not included.BZ-4913
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.