如何减少垃圾产生量? [英] How to reduce netty garbage production?

查看:146
本文介绍了如何减少垃圾产生量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网络应用程序处理使用netty框架编写的约40k msg / sec,并且我想减少垃圾回收器调用的数量。分析时,我发现有大量的 byte [] 实例,我怀疑它来自这部分代码:


$ b $ public class MessageHandler extends SimpleChannelHandler {
$ b $ public void messageReceived(ChannelHandlerContext ctx,final MessageEvent e){

ChannelBuffer message =(ChannelBuffer)e.getMessage();
}

}

是否可以强制netty重复使用/池 ChannelBuffers 以某种方式防止它每次都构造它们?

解决方案

<我们计划实施缓冲池,但尚未完成。



请参阅 https://github.com/netty/netty/issues/62


I have network application that handles about 40k msg/sec written using netty framework and I want to reduce the number of garbage collector calls. While profiling I found that there is significant amount of byte[] instances and I suspect that it comes from this part of code :

public class MessageHandler extends SimpleChannelHandler {

public void messageReceived(ChannelHandlerContext ctx, final MessageEvent e) {

    ChannelBuffer message = (ChannelBuffer) e.getMessage();
}

}

Is it possible to force netty to reuse/pool ChannelBuffers somehow to prevent it to construct them every time?

解决方案

We plan to implement pooling of buffers, but its not done yet.

See https://github.com/netty/netty/issues/62

这篇关于如何减少垃圾产生量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆