简体   繁体   English

netty API中的内存泄漏

[英]Memory leak in netty API

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. 我是netty API的新手,我使用netty3.5.2来开发客户端和服务器通信服务器,但是应用程序总是运行完整的GC,我使用jmap来转储内存并使用jhat来显示哪个对象占用了内存。
And there are 6413363 instances of DefaultChannelFuture . 并且有6413363个DefaultChannelFuture实例。 can someone tell which thread create the DefaultChannelFuture instances and how and when they will be released? 有人可以告诉哪个线程创建DefaultChannelFuture实例以及它们将如何以及何时发布?

Top 4 instances suspected 怀疑前4个案例
6413363 instances of class org.jboss.netty.channel.DefaultChannelFuture 6413363类org.jboss.netty.channel.DefaultChannelFuture实例
631971 instances of class org.jboss.netty.util.internal.LinkedTransferQueue$Node 631971类org.jboss.netty.util.internal.LinkedTransferQueue$Node实例
630934 instances of class org.jboss.netty.buffer.BigEndianHeapChannelBuffer 630934类org.jboss.netty.buffer.BigEndianHeapChannelBuffer实例
630767 instances of class org.jboss.netty.channel.DownStreamMessageEvent org.jboss.netty.channel.DownStreamMessageEvent 630767个实例

You generating messages to fast. 您生成快速消息。 It overload message queue. 它使消息队列过载。

Check nethwork load. 检查工作负荷。

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 in Action书中描述了一个检漏仪:

Netty contains a so called ResourceLeakDetector which will sample about 1% of buffer allocations to check if there is a leak in your application. Netty包含一个所谓的ResourceLeakDetector ,它将对大约1%的缓冲区分配进行采样,以检查应用程序中是否存在泄漏。 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. 泄漏:在垃圾收集之前没有调用ByteBuf.release()。 Enable advanced leak reporting to find out where the leak occurred. 启用高级泄漏报告以找出泄漏发生的位置。 To enable advanced leak reporting, specify the JVM option 要启用高级泄漏报告,请指定JVM选项

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM