java - Netty-4.0.0.CR6 抛出 OutOfMemoryError

标签 java netty out-of-memory

我正在使用最新版本的 Netty-4 CR6 尝试我的应用程序。在我的应用程序的服务器端,我在每秒大约 200 个请求的负载下收到以下错误:

io.netty.handler.codec.DecoderException: java.lang.OutOfMemoryError: Direct buffer memory
        at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:393)
        at io.netty.handler.codec.ByteToMessageDecoder.messageReceived(ByteToMessageDecoder.java:129)
        at io.netty.channel.DefaultChannelHandlerContext.invokeMessageReceived(DefaultChannelHandlerContext.java:379)
        at io.netty.channel.DefaultChannelHandlerContext.fireMessageReceived(DefaultChannelHandlerContext.java:364)
        at io.netty.channel.DefaultChannelHandlerContext.fireMessageReceived(DefaultChannelHandlerContext.java:347)
        at io.netty.channel.DefaultChannelPipeline.fireMessageReceived(DefaultChannelPipeline.java:780)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:92)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:489)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:464)
        at io.netty.channel.nio.NioEventLoop.run(NioEventL

这是一个文件传输应用程序。我正在使用使用 Netty-4 CR6 jar 构建的客户端和服务器。在每个请求中,客户端创建一个 WebSocket 连接,传输一个大约 850KB 的文件,最后通过发送 CloseWebSocketFrame 关闭连接。

最佳答案

看看下面的bug .你可能遇到过它。这里的选项是
1. 在上游处理程序中使用 msgs.releaseAll()
2. 使用 io.netty.channel.SimpleChannelInboundHandler 类作为您的消费处理程序。然后你不需要使用 releaseAll 逻辑,因为它由 netty 在内部为你处理。

关于java - Netty-4.0.0.CR6 抛出 OutOfMemoryError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17320180/

相关文章:

java - 如何将json字符串放入java中的列表中

java - 检查 Netty 服务器是否启动时 sleep 的替代方案?

android - 为什么我的带有 TabGroup 的 Titanium Android 应用程序存在内存和性能问题?

java - 使用 StringBuilder 覆盖普通 POJO 的 toString() 时避免内存效率低下

javascript - JavaScript 客户端和 Netty 服务器之间的安全 WebSocket 连接

内存不足错误后PHP自动添加错误

java - 找出重复字母最多的单词

java - 线程中的异常 "AWT-EventQueue-0"java.lang.NumberFormatException : empty String

java - 类文件格式的最终​​变量

java - 在 apache Camel 上为 HTTPS 实现 API(SSL)的最佳方法是什么?