Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-19360

java.lang.OutOfMemoryError: Direct buffer memory

XMLWordPrintable

    • Workaround Exists
    • Hide

      Configure the task thread pool with core equal to max:

      <subsystem xmlns="urn:jboss:domain:io:4.0" default-worker="default">
          <worker name="default" task-core-threads="64" task-max-threads="64"/>
      </subsystem> 

      See workaround here: https://issues.redhat.com/browse/UNDERTOW-2389

      Result is looking fine:

      Show
      Configure the task thread pool with core equal to max: <subsystem xmlns= "urn:jboss:domain:io:4.0" default -worker= " default " > <worker name= " default " task-core-threads= "64" task-max-threads= "64" /> </subsystem> See workaround here: https://issues.redhat.com/browse/UNDERTOW-2389 Result is looking fine:
    • ---
    • ---

      After the Wildfly 31 memory issue we are facing the next memory issue with Wildfly 32.0.0. All our application with W32 are impacted.

       

      exception_class
      java.lang.OutOfMemoryError
          
      exception_message
      Cannot reserve 16384 bytes of direct buffer memory (allocated: 536870913, limit: 536870912)

      stacktrace

       

      java.lang.OutOfMemoryError: Cannot reserve 16384 bytes of direct buffer memory (allocated: 536870913, limit: 536870912)
          at java.base/java.nio.Bits.reserveMemory(Unknown Source)
          at java.base/java.nio.DirectByteBuffer.<init>(Unknown Source)
          at java.base/java.nio.ByteBuffer.allocateDirect(Unknown Source)
          at io.undertow.core@2.3.13.Final //io.undertow.server.DefaultByteBufferPool.allocate(DefaultByteBufferPool.java:149)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.spec.ServletInputStreamImpl.readIntoBuffer(ServletInputStreamImpl.java:199)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.spec.ServletInputStreamImpl.close(ServletInputStreamImpl.java:266)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.spec.HttpServletRequestImpl.closeAndDrainRequest(HttpServletRequestImpl.java:731)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.core.ServletBlockingHttpExchange.close(ServletBlockingHttpExchange.java:89)
          at io.undertow.core@2.3.13.Final//io.undertow.server.HttpServerExchange.endExchange(HttpServerExchange.java:1709)
          at io.undertow.core@2.3.13.Final//io.undertow.server.AbstractServerConnection$CloseSetter.handleEvent(AbstractServerConnection.java:316)
          at io.undertow.core@2.3.13.Final//io.undertow.server.AbstractServerConnection$CloseSetter.handleEvent(AbstractServerConnection.java:296)
          at org.jboss.xnio@3.8.14.Final//org.xnio.StreamConnection.lambda$mergeListeners$1(StreamConnection.java:82)
          at org.jboss.xnio@3.8.14.Final//org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
          at org.jboss.xnio@3.8.14.Final//org.xnio.StreamConnection.invokeCloseListener(StreamConnection.java:132)
          at org.jboss.xnio@3.8.14.Final//org.xnio.Connection.close(Connection.java:142)
          at io.undertow.core@2.3.13.Final//io.undertow.server.AbstractServerConnection.close(AbstractServerConnection.java:159)
          at org.jboss.xnio@3.8.14.Final//org.xnio.IoUtils.safeClose(IoUtils.java:152)
          at io.undertow.core@2.3.13.Final//io.undertow.server.protocol.http.HttpResponseConduit.flush(HttpResponseConduit.java:772)
          at io.undertow.core@2.3.13.Final//io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.flush(AbstractFixedLengthStreamSinkConduit.java:229)
          at org.jboss.xnio@3.8.14.Final//org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
          at io.undertow.core@2.3.13.Final//io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:119)
          at org.jboss.xnio@3.8.14.Final//org.xnio.channels.Channels.flushBlocking(Channels.java:63)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:627)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:504)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:599)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:335)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:132)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
          at org.wildfly.extension.undertow@32.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1421)
          at org.wildfly.extension.undertow@32.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1421)
          at org.wildfly.extension.undertow@32.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1421)
          at org.wildfly.extension.undertow@32.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1421)
          at org.wildfly.extension.undertow@32.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1421)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:256)
          at io.undertow.servlet@2.3.13.Final//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:101)
          at io.undertow.core@2.3.13.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
          at io.undertow.core@2.3.13.Final//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
          at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
          at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
          at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
          at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1363)
          at org.jboss.xnio@3.8.14.Final//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
          at java.base/java.lang.Thread.run(Unknown Source) 

       

       

      FIX is ready:

      We saw, there exist already a fix related to this topic, which is unfortunately not merged yet:
      https://github.com/undertow-io/undertow/pull/1589/files

      A patched Widlfly with an adapted ThreadLocalCache is working fine. See screenshot:

       

        1. image-2024-05-27-07-56-32-765.png
          58 kB
          Jürg Drollinger
        2. image-2024-05-27-09-14-42-395.png
          58 kB
          Jürg Drollinger
        3. image-2024-05-27-16-50-38-260.png
          90 kB
          Jürg Drollinger

              rhn-cservice-bbaranow Bartosz Baranowski
              juerg.drollinger@six-group.com Jürg Drollinger (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: