Hot Deployment Exhausts the PermGen when the Application Uses Ehcache

Solution Verified - Updated

Environment

  • JBoss Enterprise Application Platform (EAP)

Issue

  • Our application uses Ehcache. After a couple of hot deploys of this application, JBoss throws an "OutOfMemoryError: PermGen space".

Resolution

<listener>
  <listener-class>net.sf.ehcache.constructs.web.ShutdownListener</listener-class>
</listener>

Root Cause

  • Ehcache threads (such as the cacheManagerTimer) are still running, keeping the application classloader from collection.
  • The CacheManager was not shutdown. If it were, such references and threads should have likely been cleaned up.

Diagnostic Steps

  • Troubleshoot as described in Java application "OutOfMemoryError: PermGen space"
  • Trace classloaders to GC roots and check for Ehcache references
  • Check the status of CacheManager's to determine if they are still alive
Components
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.