Closed caserzer closed 8 years ago
@caserzer, a few questions:
@nayato
can you post a repro? That would help speed up the analysis
also, when you say "only enqueue", do you release the MQTT packets / payloads? normally it is done in protocol gateway here: https://github.com/Azure/azure-iot-protocol-gateway/blob/master/src/ProtocolGateway.Core/Mqtt/MqttIotHubAdapter.cs#L335
@nayato thanks for helping. I found in my modification I simply comment theusing (Stream bodyStream = packet.Payload.IsReadable() ? new ReadOnlyByteBufferStream(packet.Payload, true) : null)
which cause the memory leak. Thanks
I'm doing MQTT load test and the application report memory leak issue, I'm not sure whether it's my code issue or the MQTT decoder issue. C:\Debug\Debug>ProtocolGateway.Host.Console.exe ProviderId : d079e771-0495-4124-bd2f-ab63c2b50525 EventId : 5 Keywords : None Level : Error Message : Opcode : Info Task : 65529 Version : 0 Payload : [source : DotNetty.Common.ResourceLeakDetector] [message : LEAK: IByte Buffer.release() was not called before it's garbage-collected. See http://netty. io/wiki/reference-counted-objects.html for more information. Recent access records: 1
1:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) at System.Environment.get_StackTrace() at DotNetty.Common.ResourceLeakDetector.NewRecord(Object hint) at DotNetty.Common.ResourceLeakDetector.DefaultResourceLeak.RecordInternal(Ob ject hint) at DotNetty.Common.ResourceLeakDetector.DefaultResourceLeak.Record() at DotNetty.Buffers.AdvancedLeakAwareByteBuffer.WriteBytes(IByteBuffer src) at DotNetty.Codecs.ByteToMessageDecoder.ExpandCumulation(IByteBufferAllocator allocator, IByteBuffer cumulation, Int32 readable) at DotNetty.Codecs.ByteToMessageDecoder.<>c.<.cctor>b27_0(IByteBufferAlloca tor allocator, IByteBuffer cumulation, IByteBuffer input) at DotNetty.Codecs.ByteToMessageDecoder.ChannelRead(IChannelHandlerContext co ntext, Object message) at DotNetty.Transport.Channels.ChannelHandlerInvokerUtil.InvokeChannelReadNow (IChannelHandlerContext ctx, Object msg) at DotNetty.Transport.Channels.DefaultChannelHandlerInvoker.InvokeChannelRead (IChannelHandlerContext ctx, Object msg) at DotNetty.Transport.Channels.AbstractChannelHandlerContext.FireChannelRead( Object msg) at DotNetty.Transport.Channels.DefaultChannelPipeline.FireChannelRead(Object msg) at DotNetty.Transport.Channels.Sockets.AbstractSocketByteChannel.SocketByteCh annelUnsafe.FinishRead(SocketChannelAsyncOperation operation) at DotNetty.Transport.Channels.Sockets.AbstractSocketChannel.<>c.<.cctor>b__4 3_1(Object u, Object e) at DotNetty.Common.Concurrency.AbstractEventExecutor.StateActionWithContextTa skQueueNode.Run() at DotNetty.Common.Concurrency.SingleThreadEventExecutor.RunAllTasks(PreciseT imeSpan timeout) at DotNetty.Common.Concurrency.SingleThreadEventExecutor.b 22_0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
at System.Threading.Tasks.TaskScheduler.TryExecuteTask(Task task)
at DotNetty.Common.Concurrency.ExecutorTaskScheduler.QueueTask(Task task)
at System.Threading.Tasks.Task.ScheduleAndStart(Boolean needsProtection)
at System.Threading.Tasks.Task.InternalStartNew(Task creatingTask, Delegate a
ction, Object state, CancellationToken cancellationToken, TaskScheduler schedule
r, TaskCreationOptions options, InternalTaskOptions internalOptions, StackCrawlM
ark& stackMark)
at System.Threading.Tasks.TaskFactory.StartNew(Action action, CancellationTok
en cancellationToken, TaskCreationOptions creationOptions, TaskScheduler schedul
er)
at DotNetty.Common.Concurrency.SingleThreadEventExecutor.Loop()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()Created at:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at DotNetty.Common.ResourceLeakDetector.NewRecord(Object hint)
at DotNetty.Common.ResourceLeakDetector.DefaultResourceLeak..ctor(ResourceLea
kDetector owner, Object referent)
at DotNetty.Common.ResourceLeakDetector.Open(Object obj)
at DotNetty.Buffers.AbstractByteBufferAllocator.ToLeakAwareBuffer(IByteBuffer
buf)
at DotNetty.Buffers.PooledByteBufferAllocator.NewBuffer(Int32 initialCapacity
, Int32 maxCapacity)
at DotNetty.Buffers.AbstractByteBufferAllocator.Buffer(Int32 initialCapacity)
at DotNetty.Codecs.ByteToMessageDecoder.ExpandCumulation(IByteBufferAllocator allocator, IByteBuffer cumulation, Int32 readable) at DotNetty.Codecs.ByteToMessageDecoder.<>c.<.cctor>b27_0(IByteBufferAlloca tor allocator, IByteBuffer cumulation, IByteBuffer input) at DotNetty.Codecs.ByteToMessageDecoder.ChannelRead(IChannelHandlerContext co ntext, Object message) at DotNetty.Transport.Channels.ChannelHandlerInvokerUtil.InvokeChannelReadNow (IChannelHandlerContext ctx, Object msg) at DotNetty.Transport.Channels.DefaultChannelHandlerInvoker.InvokeChannelRead (IChannelHandlerContext ctx, Object msg) at DotNetty.Transport.Channels.AbstractChannelHandlerContext.FireChannelRead( Object msg) at DotNetty.Transport.Channels.DefaultChannelPipeline.FireChannelRead(Object msg) at DotNetty.Transport.Channels.Sockets.AbstractSocketByteChannel.SocketByteCh annelUnsafe.FinishRead(SocketChannelAsyncOperation operation) at DotNetty.Transport.Channels.Sockets.AbstractSocketChannel.<>c.<.cctor>b__4 3_1(Object u, Object e) at DotNetty.Common.Concurrency.AbstractEventExecutor.StateActionWithContextTa skQueueNode.Run() at DotNetty.Common.Concurrency.SingleThreadEventExecutor.RunAllTasks(PreciseT imeSpan timeout) at DotNetty.Common.Concurrency.SingleThreadEventExecutor.b 22_0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
at System.Threading.Tasks.TaskScheduler.TryExecuteTask(Task task)
at DotNetty.Common.Concurrency.ExecutorTaskScheduler.QueueTask(Task task)
at System.Threading.Tasks.Task.ScheduleAndStart(Boolean needsProtection)
at System.Threading.Tasks.Task.InternalStartNew(Task creatingTask, Delegate a
ction, Object state, CancellationToken cancellationToken, TaskScheduler schedule
r, TaskCreationOptions options, InternalTaskOptions internalOptions, StackCrawlM
ark& stackMark)
at System.Threading.Tasks.TaskFactory.StartNew(Action action, CancellationTok
en cancellationToken, TaskCreationOptions creationOptions, TaskScheduler schedul
er)
at DotNetty.Common.Concurrency.SingleThreadEventExecutor.Loop()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart] [exception : ]
EventName : ErrorInfo
Timestamp : 2016-06-04T18:02:26.4820537Z
ProcessId : 4212
ThreadId : 1820
ProviderId : d079e771-0495-4124-bd2f-ab63c2b50525 EventId : 5 Keywords : None Level : Error Message : Opcode : Info Task : 65529 Version : 0 Payload : [source : DotNetty.Common.ResourceLeakDetector] [message : LEAK: IByte Buffer.release() was not called before it's garbage-collected. See http://netty. io/wiki/reference-counted-objects.html for more information. Recent access records: 1
1:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) at System.Environment.get_StackTrace() at DotNetty.Common.ResourceLeakDetector.NewRecord(Object hint) at DotNetty.Common.ResourceLeakDetector.DefaultResourceLeak.RecordInternal(Ob ject hint) at DotNetty.Common.ResourceLeakDetector.DefaultResourceLeak.Record(Object hin t) at DotNetty.Buffers.AdvancedLeakAwareByteBuffer.Touch(Object hint) at DotNetty.Common.Utilities.ReferenceCountUtil.Touch[T](T msg, Object hint) at DotNetty.Transport.Channels.AbstractChannelHandlerContext.FireChannelRead( Object msg) at DotNetty.Transport.Channels.DefaultChannelPipeline.FireChannelRead(Object msg) at DotNetty.Transport.Channels.Sockets.AbstractSocketByteChannel.SocketByteCh annelUnsafe.FinishRead(SocketChannelAsyncOperation operation) at DotNetty.Transport.Channels.Sockets.AbstractSocketChannel.<>c.<.cctor>b__4 3_1(Object u, Object e) at DotNetty.Common.Concurrency.AbstractEventExecutor.StateActionWithContextTa skQueueNode.Run() at DotNetty.Common.Concurrency.SingleThreadEventExecutor.RunAllTasks(PreciseT imeSpan timeout) at DotNetty.Common.Concurrency.SingleThreadEventExecutor.b__22_0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
at System.Threading.Tasks.TaskScheduler.TryExecuteTask(Task task)
at DotNetty.Common.Concurrency.ExecutorTaskScheduler.QueueTask(Task task)
at System.Threading.Tasks.Task.ScheduleAndStart(Boolean needsProtection)
at System.Threading.Tasks.Task.InternalStartNew(Task creatingTask, Delegate a
ction, Object state, CancellationToken cancellationToken, TaskScheduler schedule
r, TaskCreationOptions options, InternalTaskOptions internalOptions, StackCrawlM
ark& stackMark)
at System.Threading.Tasks.TaskFactory.StartNew(Action action, CancellationTok
en cancellationToken, TaskCreationOptions creationOptions, TaskScheduler schedul
er)
at DotNetty.Common.Concurrency.SingleThreadEventExecutor.Loop()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()Created at:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at DotNetty.Common.ResourceLeakDetector.NewRecord(Object hint)
at DotNetty.Common.ResourceLeakDetector.DefaultResourceLeak..ctor(ResourceLea
kDetector owner, Object referent)
at DotNetty.Common.ResourceLeakDetector.Open(Object obj)
at DotNetty.Buffers.AbstractByteBufferAllocator.ToLeakAwareBuffer(IByteBuffer
buf)
at DotNetty.Buffers.PooledByteBufferAllocator.NewBuffer(Int32 initialCapacity
, Int32 maxCapacity)
at DotNetty.Buffers.AbstractByteBufferAllocator.Buffer(Int32 initialCapacity)
at DotNetty.Transport.Channels.FixedRecvByteBufAllocator.HandleImpl.Allocate( IByteBufferAllocator alloc) at DotNetty.Transport.Channels.Sockets.AbstractSocketByteChannel.SocketByteCh annelUnsafe.FinishRead(SocketChannelAsyncOperation operation) at DotNetty.Transport.Channels.Sockets.AbstractSocketChannel.<>c.<.cctor>b__4 3_1(Object u, Object e) at DotNetty.Common.Concurrency.AbstractEventExecutor.StateActionWithContextTa skQueueNode.Run() at DotNetty.Common.Concurrency.SingleThreadEventExecutor.RunAllTasks(PreciseT imeSpan timeout) at DotNetty.Common.Concurrency.SingleThreadEventExecutor.b__22_0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
at System.Threading.Tasks.TaskScheduler.TryExecuteTask(Task task)
at DotNetty.Common.Concurrency.ExecutorTaskScheduler.QueueTask(Task task)
at System.Threading.Tasks.Task.ScheduleAndStart(Boolean needsProtection)
at System.Threading.Tasks.Task.InternalStartNew(Task creatingTask, Delegate a
ction, Object state, CancellationToken cancellationToken, TaskScheduler schedule
r, TaskCreationOptions options, InternalTaskOptions internalOptions, StackCrawlM
ark& stackMark)
at System.Threading.Tasks.TaskFactory.StartNew(Action action, CancellationTok
en cancellationToken, TaskCreationOptions creationOptions, TaskScheduler schedul
er)
at DotNetty.Common.Concurrency.SingleThreadEventExecutor.Loop()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionCo
ntext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart] [exception : ]
EventName : ErrorInfo
Timestamp : 2016-06-04T18:02:26.5914240Z
ProcessId : 4212
ThreadId : 1820