Am 24. Juni 2014 bei 20:17:56, ryan.sl...@gmail.com (ryan.sl...@gmail.com) schrieb:
What is the deal with reference counting in Netty 4? Do I need to explicitly release the message object in my class which extends ChannelInboundHandlerAdapter? The user guide (http://netty.io/wiki/user-guide-for-4.x.html) suggests that I would if I was dealing with a ByteBuf, but I'm relying on the DelimiterBasedFrameDecoder and StringDecoder in the pipeline ahead of my handler to present me with a simple String so I guess I don't have to worry about reference counting now, but I'm not sure?
You are right you will not need to worry then. Or just extend SimpleChannelInboundHandler which will take care of this for you-
I stumbled on the Wiki about this too (http://netty.io/wiki/reference-counted-objects.html), but I'm still not 100% sure what the API expects me to do to avoid a memory leak. By the way, requiring API users to think about reference counting is not good for usability.
The problem is that without pooling direct buffers you will not get the best out of performance and as we not know when you not the ByteBuf anymore we need you to release it. And no GC will not work week enough here as the GC may not kick in fast enough if using direct buffers (as these are not allocated out of the heap).
--