You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "James Netherton (JIRA)" <ji...@apache.org> on 2015/10/06 16:41:26 UTC

[jira] [Created] (CAMEL-9195) Memory leak in UndertowProducer

James Netherton created CAMEL-9195:
--------------------------------------

             Summary: Memory leak in UndertowProducer
                 Key: CAMEL-9195
                 URL: https://issues.apache.org/jira/browse/CAMEL-9195
             Project: Camel
          Issue Type: Bug
          Components: camel-undertow
    Affects Versions: 2.16.0
            Reporter: James Netherton


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.  

{code}
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");
    }
}

{code}

{code}
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
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)