mrniko / netty-socketio

Socket.IO server implemented on Java. Realtime java framework
Apache License 2.0
6.82k stars 1.65k forks source link

Memory Leak #98

Closed marad closed 10 years ago

marad commented 10 years ago

I get below exception sometimes in version 1.5.4.

WARNING: LEAK: ByteBuf was GC'd before being released correctly. The following stack trace shows where the leaked object was created, rather than where you failed to release it. io.netty.util.ResourceLeakException: io.netty.buffer.UnpooledUnsafeDirectByteBuf@c2c69f at io.netty.util.ResourceLeakDetector$DefaultResourceLeak.(ResourceLeakDetector.java:175) at io.netty.util.ResourceLeakDetector.open(ResourceLeakDetector.java:117) at io.netty.buffer.UnpooledUnsafeDirectByteBuf.(UnpooledUnsafeDirectByteBuf.java:72) at io.netty.buffer.UnpooledByteBufAllocator.newDirectBuffer(UnpooledByteBufAllocator.java:49) at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:133) at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:124) at io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:77) at com.corundumstudio.socketio.parser.Encoder.allocateBuffer(Encoder.java:47) at com.corundumstudio.socketio.SocketIOEncoder.write(SocketIOEncoder.java:174) at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:645) at io.netty.channel.DefaultChannelHandlerContext.access$2000(DefaultChannelHandlerContext.java:29) at io.netty.channel.DefaultChannelHandlerContext$WriteTask.run(DefaultChannelHandlerContext.java:906) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) at java.lang.Thread.run(Thread.java:744)

mrniko commented 10 years ago

Have you tried an 1.6.1 version?

marad commented 10 years ago

Well. I've noticed that there is 1.6.1 version and we switched to it today. I'll let you know if this still happens.

mrniko commented 10 years ago

@marad I just added a logging of such cases. Please, use build from "master" and watch for follow warnings in your log: "Buf for message: ... has not been deallocated."

marad commented 10 years ago

Thanks! I think for now we'll stick to the 1.6.1 from the maven repo. If the issue persists we'll give the most recent github version a try.

mrniko commented 10 years ago

please, reopen if bug repeats

michalkijas commented 10 years ago

Hello. Probably the problem comes back. I use version netty-socketio 1.6.2 with netty 4.0.17.Final

22830 [nioEventLoopGroup-3-10] ERROR io.netty.util.ResourceLeakDetector - LEAK: ByteBuf.release() was not called before it's garbage-collected. Recent access records: 1

1:

  io.netty.buffer.AdvancedLeakAwareByteBuf.internalNioBuffer(AdvancedLeakAwareByteBuf.java:691)
  io.netty.buffer.ByteBufUtil.encodeString(ByteBufUtil.java:340)
  io.netty.buffer.Unpooled.copiedBuffer(Unpooled.java:660)
  io.netty.buffer.Unpooled.copiedBuffer(Unpooled.java:597)
  com.corundumstudio.socketio.transport.FlashPolicyHandler.<init>(FlashPolicyHandler.java:30)
  com.corundumstudio.socketio.SocketIOChannelInitializer.<init>(SocketIOChannelInitializer.java:88)
  com.corundumstudio.socketio.SocketIOServer.<init>(SocketIOServer.java:52)
  ...
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:606)
  org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
  java.lang.Thread.run(Thread.java:744)
  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.buffer(AbstractByteBufAllocator.java:83)
  io.netty.buffer.ByteBufUtil.encodeString(ByteBufUtil.java:338)
  io.netty.buffer.Unpooled.copiedBuffer(Unpooled.java:660)
  io.netty.buffer.Unpooled.copiedBuffer(Unpooled.java:597)
  com.corundumstudio.socketio.transport.FlashPolicyHandler.<init>(FlashPolicyHandler.java:30)
  com.corundumstudio.socketio.SocketIOChannelInitializer.<init>(SocketIOChannelInitializer.java:88)
  com.corundumstudio.socketio.SocketIOServer.<init>(SocketIOServer.java:52)
  ...
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.lang.reflect.Method.invoke(Method.java:606)
  org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
  java.lang.Thread.run(Thread.java:744)
mrniko commented 10 years ago

@skibi Very strange. Have seen in log records like? Buf for message: .... has not been deallocated, refCnt: ....! Forcing release it!