You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Gijsbert van den Brink (JIRA)" <ji...@apache.org> on 2015/05/28 10:16:17 UTC

[jira] [Created] (CAMEL-8812) Memory leak in HL7MLLPNettyDecoder

Gijsbert van den Brink created CAMEL-8812:
---------------------------------------------

             Summary: Memory leak in HL7MLLPNettyDecoder
                 Key: CAMEL-8812
                 URL: https://issues.apache.org/jira/browse/CAMEL-8812
             Project: Camel
          Issue Type: Bug
          Components: camel-hl7
    Affects Versions: 2.15.2
            Reporter: Gijsbert van den Brink


HL7MLLPNettyDecoder leaks memory because it doesn't release the Netty ByteBuf it uses.

Checkout http://netty.io/wiki/reference-counted-objects.html for more information about Netty ByteBuf and preventing leaks.

When I set the leak detection level to paranoid (-Dio.netty.leakDetectionLevel=paranoid) I get consistent leak reports like the one below.

I think the solution is to call buf.release() in the decode() method after it's done with buf. But I'm still trying to reproduce this in a unit test.


2015-05-28 10:13:48,951 ERROR io.netty.util.ResourceLeakDetector - LEAK: ByteBuf.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.
Recent access records: 5
#5:
	io.netty.buffer.AdvancedLeakAwareByteBuf.release(AdvancedLeakAwareByteBuf.java:45)
	io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:236)
	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
	io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
	io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847)
	io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
	io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
	io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
	io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
	io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
	io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
	java.lang.Thread.run(Thread.java:745)
#4:
	io.netty.buffer.AdvancedLeakAwareByteBuf.toString(AdvancedLeakAwareByteBuf.java:697)
	org.apache.camel.component.hl7.HL7MLLPNettyDecoder.asString(HL7MLLPNettyDecoder.java:90)
	org.apache.camel.component.hl7.HL7MLLPNettyDecoder.decode(HL7MLLPNettyDecoder.java:66)
	io.netty.handler.codec.DelimiterBasedFrameDecoder.decode(DelimiterBasedFrameDecoder.java:216)
	io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:315)
	io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:229)
	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
	io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
	io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847)
	io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
	io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
	io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
	io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
	io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
	io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
	java.lang.Thread.run(Thread.java:745)
#3:
	io.netty.buffer.AdvancedLeakAwareByteBuf.slice(AdvancedLeakAwareByteBuf.java:73)
	org.apache.camel.component.hl7.HL7MLLPNettyDecoder.decode(HL7MLLPNettyDecoder.java:64)
	io.netty.handler.codec.DelimiterBasedFrameDecoder.decode(DelimiterBasedFrameDecoder.java:216)
	io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:315)
	io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:229)
	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
	io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
	io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847)
	io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
	io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
	io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
	io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
	io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
	io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
	java.lang.Thread.run(Thread.java:745)
#2:
	io.netty.buffer.AdvancedLeakAwareByteBuf.bytesBefore(AdvancedLeakAwareByteBuf.java:607)
	org.apache.camel.component.hl7.HL7MLLPNettyDecoder.decode(HL7MLLPNettyDecoder.java:62)
	io.netty.handler.codec.DelimiterBasedFrameDecoder.decode(DelimiterBasedFrameDecoder.java:216)
	io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:315)
	io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:229)
	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
	io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
	io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847)
	io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
	io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
	io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
	io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
	io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
	io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
	java.lang.Thread.run(Thread.java:745)
#1:
	io.netty.buffer.AdvancedLeakAwareByteBuf.retain(AdvancedLeakAwareByteBuf.java:709)
	io.netty.handler.codec.DelimiterBasedFrameDecoder.decode(DelimiterBasedFrameDecoder.java:277)
	org.apache.camel.component.hl7.HL7MLLPNettyDecoder.decode(HL7MLLPNettyDecoder.java:60)
	io.netty.handler.codec.DelimiterBasedFrameDecoder.decode(DelimiterBasedFrameDecoder.java:216)
	io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:315)
	io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:229)
	io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
	io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
	io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847)
	io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
	io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
	io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
	io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
	io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
	io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
	java.lang.Thread.run(Thread.java:745)
Created at:
	io.netty.buffer.UnpooledByteBufAllocator.newDirectBuffer(UnpooledByteBufAllocator.java:55)
	io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:155)
	io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:146)
	io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:107)
	io.netty.channel.AdaptiveRecvByteBufAllocator$HandleImpl.allocate(AdaptiveRecvByteBufAllocator.java:104)
	io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:117)
	io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
	io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
	io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
	io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
	io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
	java.lang.Thread.run(Thread.java:745)




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