java - HttpObjectAggregator 处的 Netty 4 泄漏异常

标签 java networking netty

我的 netty 服务器在负载较重时遇到异常。 (使用 LOIC 等进行测试...)我想知道我做错了什么,或者这是 HttpObjectAggregator 中的错误。

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.CompositeByteBuf@1c0eeb6
    at io.netty.util.ResourceLeakDetector$DefaultResourceLeak.<init>(ResourceLeakDetector.java:174)
    at io.netty.util.ResourceLeakDetector.open(ResourceLeakDetector.java:116)
    at io.netty.buffer.CompositeByteBuf.<init>(CompositeByteBuf.java:60)
    at io.netty.buffer.Unpooled.compositeBuffer(Unpooled.java:353)
    at io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:138)
    at io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:50)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89)
    at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:334)
    at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:320)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:173)
    at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:334)
    at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:320)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:100)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:497)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:465)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:359)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
    at java.lang.Thread.run(Thread.java:722)

最佳答案

很可能您在处理消息后忘记释放该消息。你调用release()了吗?

关于java - HttpObjectAggregator 处的 Netty 4 泄漏异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18307753/

相关文章:

java - 将整数数组转换为 Long

java - decode() 没有读取任何内容,但解码了一条消息

java - 在 Netty 中处理多格式数据

java - 如何在 Netty 中分块 List<Object>

java - GridBag布局和绘图

java - Jcommander 使用格式

java - 在 Eclipse 中管理库

c++ - 套接字编程: sending packet on UDP (C++)

apache - 将 HTTPS 443 端口重定向到其他服务器上的多个站点

security - 保护部分 HTTP 请求?