OutOfMemoryError in JBoss 7.4.0 GA due to tag handlers throwing exceptions and leaking in org.jboss.as.web.common.WebInjectionContainer

175 views
Skip to first unread message

Larry Beaty

unread,
May 28, 2024, 7:24:13 AM5/28/24
to WildFly
Sorry, I don't know which version of Wildfly JBoss EAP 7.4.0 corresponds to.

We have custom tag handlers in JBoss 7.4.0 GA that throw exceptions during normal operation, and they result in a Java "memory leak" (which ultimately result in an OutOfMemoryError) due to being retained by the org.jboss.as.web.common.WebInjectionContainer variable named webInjectionContainer, of the org.wildfly.extension.undertow.deployment.UndertowJSPInstanceManager.

How can I prevent the JSP InstanceManager from holding on to this reference to the Tag? 

I have tried setting tag-pooling to false,
-Dorg.apache.jasper.runtime.JspFactoryImpl.USE_POOL=false, and  
-Dorg.apache.jasper.Constants.USE_INSTANCE_MANAGER_FOR_TAGS=false,
but the reference remains.

GC root trace:
contextref of My.Tag (0x16b215)
  keyRef of org.jboss.as.web.common.ConcurrentReferenceHashMap$HashEntry (0x16b214)
    element of org.jboss.as.web.common.ConcurrentReferenceHashMap$HashEntry[ ] (0x1b3ad8)
      table of org.jboss.as.web.common.ConcurrentReferenceHashMap$Segment (0x16b212)
        element of org.jboss.as.web.common.ConcurrentReferenceHashMap$Segment[ ] (0x1a3592)
          segments of org.jboss.as.web.common.ConcurrentReferenceHashMap (0x84914)
            instanceMap of org.jboss.as.web.common.WebInjectionContainer (0x84913)
              webInjectionContainer of org.wildfly.extension.undertow.deployment.UndertowJSPInstanceManager (0x84912)

The tags referred to here are custom tags that inherit from javax.servlet.jsp.tagext.BodyTagSupport.

This bug is not JBWEB-242 (a tag-pooling memory leak).  It might be JBWEB-269 "Memory Leak when Custom Tags Throw Runtime Exception", but I cannot see the description of that report at https://issues.jboss.org/browse/JBWEB-269  .  The technical issue is that the JSP is compiled into Java code that does not use a finally clause to guarantee that the _jsp_instancemanager.destroyInstance() method is called when the tag's doStartTag() or other methods throw a javax.servlet.jsp.JspTagException or RuntimeException.  (The finally clause should also be used to guarantee that the tag's release() method is called, but that is not the root of the problem here.  It would be the root of a problem is tag pooling were in use.)


John Saccoccio

unread,
May 29, 2024, 9:03:14 AM5/29/24
to WildFly
Years ago we had a similar issue in Wildfly.  Not sure how Wildfly's configuration relates to JBoss EAP, but this disable has been in place in our standalone-full.xml configuration file since:
<servlet-container name="default">
                <jsp-config tag-pooling="false"/>

Larry Beaty

unread,
May 30, 2024, 9:10:39 PM5/30/24
to WildFly
In JBoss 6, we had to disable tag-pooling (as you showed) AND disable the instance manager via 
-Dorg.apache.jasper.Constants.USE_INSTANCE_MANAGER_FOR_TAGS=false 
to prevent these particular Tag-related memory leaks.  However, the configuration variable for disabling the use of the instance manager for Tags seems to be completely ignored in JBoss 7.  Hence, this looks like a huge regression to us, and makes JBoss 7 completely unusable for our application.

Reply all
Reply to author
Forward
0 new messages