[undertow-dev] java.lang.OutOfMemoryError: Direct buffer memory

Stuart Douglas sdouglas at redhat.com
Sun Feb 12 18:02:47 EST 2017


I just had a quick look and I don't seem to be able to reproduce this.

What memory settings are you using? If you increase the available
memory does the problem go away (i.e. is it a leak or is there just
not enough direct buffer space to meet the servers needs)?

One of the changes is that buffers in 1.4.x are allocated in an
individual basis, rather than a large buffer being allocated and then
sliced. This does make initial allocation into the pool slightly more
expensive, however it means that if an application accidentally leaks
a buffer the garbage collector can take care of it. Its possible this
change in allocation behavior may be behind it if memory is
constrained.

Stuart

On Mon, Feb 13, 2017 at 12:10 AM, Steve Hu <stevehu at gmail.com> wrote:
> Hi,
>
> I am working on the benchmark tests for TechEmpower and the following
> handler got OutOfMemoryError. The tricky thing is 1.2.5.Final works fine but
> 1.4.4.Final/1.4.10.Final fails with the error.
>
> I am wondering what has been changed between 1.2 and 1.4 might cause the
> problem. The application is running within a vagrant environment and memory
> might be constraint.
>
> Thanks,
>
> Steve
>
> public class PlaintextGetHandler implements HttpHandler {
>     private static final String MESSAGE = "Hello, World!";
>
>     @Override
>     public void handleRequest(HttpServerExchange exchange) throws Exception
> {
>         exchange.getResponseHeaders().put(Headers.CONTENT_TYPE,
> "text/plain");
>         exchange.getResponseSender().send(MESSAGE);
>     }
> }
>
>
> and the stacktrace
>
> Server light-java: java.lang.OutOfMemoryError: Direct buffer memory
> Server light-java:  at java.nio.Bits.reserveMemory(Bits.java:693)
> Server light-java:  at
> java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123)
> Server light-java:  at
> java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311)
> Server light-java:  at
> io.undertow.server.DefaultByteBufferPool.allocate(DefaultByteBufferPool.java:146)
> Server light-java:  at
> io.undertow.server.protocol.http.PipeliningBufferingStreamSinkConduit.write(PipeliningBufferingStreamSinkConduit.java:98)
> Server light-java:  at
> io.undertow.server.protocol.http.HttpResponseConduit.processWrite(HttpResponseConduit.java:250)
> Server light-java:  at
> io.undertow.server.protocol.http.HttpResponseConduit.write(HttpResponseConduit.java:596)
> Server light-java:  at
> io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.write(AbstractFixedLengthStreamSinkConduit.java:106)
> Server light-java:  at
> io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.write(AbstractFixedLengthStreamSinkConduit.java:120)
> Server light-java:  at
> org.xnio.conduits.ConduitStreamSinkChannel.write(ConduitStreamSinkChannel.java:154)
> Server light-java:  at
> io.undertow.channels.DetachableStreamSinkChannel.write(DetachableStreamSinkChannel.java:187)
> Server light-java:  at
> io.undertow.server.HttpServerExchange$WriteDispatchChannel.write(HttpServerExchange.java:2021)
> Server light-java:  at
> io.undertow.io.AsyncSenderImpl.send(AsyncSenderImpl.java:219)
> Server light-java:  at
> io.undertow.io.AsyncSenderImpl.send(AsyncSenderImpl.java:310)
> Server light-java:  at
> io.undertow.io.AsyncSenderImpl.send(AsyncSenderImpl.java:282)
> Server light-java:  at
> io.undertow.io.AsyncSenderImpl.send(AsyncSenderImpl.java:316)
> Server light-java:  at
> com.networknt.techempower.handler.PlaintextGetHandler.handleRequest(PlaintextGetHandler.java:20)
> Server light-java:  at
> io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93)
> Server light-java:  at
> io.undertow.server.handlers.SetHeaderHandler.handleRequest(SetHeaderHandler.java:90)
> Server light-java:  at
> io.undertow.server.Connectors.executeRootHandler(Connectors.java:211)
> Server light-java:  at
> io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:243)
> Server light-java:  at
> io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:134)
> Server light-java:  at
> io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:58)
> Server light-java:  at
> org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
> Server light-java:  at
> org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
> Server light-java:  at
> org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:88)
> Server light-java:  at org.xnio.nio.WorkerThread.run(WorkerThread.java:559)
>
>
>
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev


More information about the undertow-dev mailing list