JBoss - Java heap retention in org.jboss.ejb.EntityEnterpriseContext

Solution Unverified - Updated

Environment

  • JBoss Enterprise Application Platform (EAP) 4.2

Issue

  • "java.lang.OutOfMemoryError: Java heap space" errors are received because the heap is consumed by org.jboss.ejb.EntityEnterpriseContext. This retention traces back to the org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy.

Resolution

  • Increase heap to allow for this cache's potential max capacity

  • Decrease this cache's max capacity to fit within the constraints of current heap sizes. To adjust this max-capacity for this cache, you can edit the container configuration that you're using directly in conf/standardjboss.xml, for example:

      <container-cache-conf>
        <cache-policy>org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy</cache-policy>
        <cache-policy-conf>
          <min-capacity>50</min-capacity>
          <max-capacity>1000000</max-capacity>
          <overager-period>300</overager-period>
          <max-bean-age>600</max-bean-age>
          <resizer-period>400</resizer-period>
          <max-cache-miss-period>60</max-cache-miss-period>
          <min-cache-miss-period>1</min-cache-miss-period>
          <cache-load-factor>0.75</cache-load-factor>
        </cache-policy-conf>
      </container-cache-conf>
    

    Or you can override the container configuration in your EJB jar's META-INF/jboss.xml as described in http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/EJBDeployer_MBean-Container_configuration_information.html.

Root Cause

  • The default size of this cache is 1000000 and so it grow to use a large amount of heap before any entries are removed based upon the LRU policy

Diagnostic Steps

Components
Category
Tags

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.