Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.16.0
-
Component/s: camel-undertow
-
Labels:None
-
Estimated Complexity:Unknown
Description
The UndertowProducer class leaks memory over time due to the repeated creation of ByteBufferSlicePool for each HTTP client request. My understanding of this class is that instances of it should be limited and cached if possible.
Here's an example RouteBuilder to replicate the issue. In a short time it will result in an OutOfMemoryError.
public class UndertowRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from("undertow:http://localhost:8080/test").to("log:undertow?showAll=true"); from("timer:foo?period=5000").transform(constant("hello world")).to("undertow:http://localhost:8080/test"); } }
org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-worklaptop-50317-1444141557043-2-30][Message: hello world] at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1658) at org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:345) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:156) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190) at org.apache.camel.processor.Pipeline.process(Pipeline.java:121) at org.apache.camel.processor.Pipeline.process(Pipeline.java:83) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190) at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:165) at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:73) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) Caused by: java.lang.OutOfMemoryError: Direct buffer memory at java.nio.Bits.reserveMemory(Bits.java:658) at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123) at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311) at org.xnio.BufferAllocator$2.allocate(BufferAllocator.java:57) at org.xnio.BufferAllocator$2.allocate(BufferAllocator.java:55) at org.xnio.ByteBufferSlicePool.allocate(ByteBufferSlicePool.java:143) at io.undertow.client.http.HttpRequestConduit.processWrite(HttpRequestConduit.java:98) at io.undertow.client.http.HttpRequestConduit.write(HttpRequestConduit.java:460) at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.write(AbstractFixedLengthStreamSinkConduit.java:106) at org.xnio.conduits.ConduitStreamSinkChannel.write(ConduitStreamSinkChannel.java:150) at io.undertow.channels.DetachableStreamSinkChannel.write(DetachableStreamSinkChannel.java:240) at org.apache.camel.component.undertow.UndertowProducer$UndertowProducerCallback.completed(UndertowProducer.java:166) at org.apache.camel.component.undertow.UndertowProducer$UndertowProducerCallback.completed(UndertowProducer.java:121) at io.undertow.client.http.HttpClientExchange.invokeReadReadyCallback(HttpClientExchange.java:190) at io.undertow.client.http.HttpClientConnection.initiateRequest(HttpClientConnection.java:293) at io.undertow.client.http.HttpClientConnection.sendRequest(HttpClientConnection.java:228) at org.apache.camel.component.undertow.UndertowProducer.process(UndertowProducer.java:102) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:141) ... 10 more