Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory leak in netty API

Tags:

java

netty

I am new to netty API and I am using netty3.5.2 to develop client and server communication server, but the app always run full GC, I use jmap to dump the memory and use jhat to show which object occupied the memory.
And there are 6413363 instances of DefaultChannelFuture. can someone tell which thread create the DefaultChannelFuture instances and how and when they will be released?

Top 4 instances suspected
6413363 instances of class org.jboss.netty.channel.DefaultChannelFuture
631971 instances of class org.jboss.netty.util.internal.LinkedTransferQueue$Node
630934 instances of class org.jboss.netty.buffer.BigEndianHeapChannelBuffer
630767 instances of class org.jboss.netty.channel.DownStreamMessageEvent

like image 492
user2093754 Avatar asked Apr 24 '14 06:04

user2093754


2 Answers

You generating messages to fast. It overload message queue.

Check nethwork load.

like image 96
talex Avatar answered Sep 19 '22 14:09

talex


This question is a bit old now so not sure if you have found an answer. I haven't used it but the Netty in Action book describes a leak detector:

Netty contains a so called ResourceLeakDetector which will sample about 1% of buffer allocations to check if there is a leak in your application. In case of a detected leak you will see a log message similar to the following:

LEAK: ByteBuf.release() was not called before it's garbage-collected. Enable advanced leak reporting to find out where the leak occurred. To enable advanced leak reporting, specify the JVM option

-Dio.netty.leakDetectionLevel=advanced or call ResourceLeakDetector.setLevel()

like image 32
paziwatts Avatar answered Sep 18 '22 14:09

paziwatts