Skip to content

Reuse receive buffer with FramedRead #6579

Answered by Darksonn
erenon asked this question in Q&A
Discussion options

You must be logged in to vote

Actually, it is not necessarily the case that a new buffer is allocated for each message. If you make sure to drop the BytesMut before you call next again, then when it calls BytesMut::reserve, it will notice that the refcount of the BytesMut is 1 which allows it to reuse the existing allocation.

Replies: 1 comment 1 reply

Comment options

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

Answer selected by erenon
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