天蓬老师2017-04-17 17:49:56
ReferenceCountUtil.release() is actually a wrapper of the ByteBuf.release() method (inherited from the ReferenceCounted interface). ByteBuf in netty4 uses reference counting (netty4 implements an optional ByteBuf pool). The reference count value of each newly allocated ByteBuf is 1. Each time a reference is added to this ByteBuf object, the ByteBuf.retain() method needs to be called. , and every time a reference is reduced, the ByteBuf.release() method needs to be called. When the reference count value of this ByteBuf object is 0, it means that this object can be recycled. I just use ByteBuf to illustrate this. There are other objects that implement the ReferenceCounted interface. The same applies at this time.
PHPz2017-04-17 17:49:56
ByteBufs read from InBound must be released manually, and ByteBufs created by oneself must be released by oneself. This release method needs to be called in these two places.
When writing Bytebuf to OutBound, netty is responsible for releasing it, and there is no need to manually call release