Skip to content

How to correctly reutilize the ByteBuf #12722

Answered by chrisvest
PedroMPagani asked this question in Q&A
Discussion options

You must be logged in to vote

Every ChannelHandlerContext.write() will release() the buffers when the data is handed over to the kernel.

You need to add retain() calls to keep the buffers alive. The retain() and release() calls will pair up to cancel out, until a release() is paired with the buffer allocation itself, and the buffer is deallocated. The refCnt: 0 message is telling you that the buffer has been deallocated.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@PedroMPagani
Comment options

@chrisvest
Comment options

Answer selected by PedroMPagani
Comment options

You must be logged in to vote
1 reply
@chrisvest
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants