Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce netty garbage production?

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?

like image 687
Egor Lakomkin Avatar asked Feb 02 '12 08:02

Egor Lakomkin


People also ask

Why Netty is fast?

It supports SSL/TLS, has both blocking and non-blocking unified APIs, and a flexible threading model. It's also fast and performant. Netty's asynchronous, non-blocking I/O model is designed for highly scalable architectures and may allow for higher throughput than an analogous blocking model.

Which method is used to clear garbage?

The gc() method is used to invoke the garbage collector to perform cleanup processing. The gc() is found in System and Runtime classes.


1 Answers

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

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

like image 75
Norman Maurer Avatar answered Sep 27 '22 18:09

Norman Maurer