简体   繁体   中英

Why Netty's CompositeByteBuf consolidates automatically if the number of components in CompositeByteBuf exceeds 'maxNumComponents'

I'm trying to understand why CompositeByteBuf, consolidates if the number of components in the compositebytebuf becomes more than 'maxNumComponents' while adding component ?

This consolidation involves copy operations . My questions are -

  1. why CompositeByteBuf is doing this consolidation automatically if the number of components is greater than 'maxNumComponents'? what is the advantage in doing so?
  2. Will there be any disadvantage if we explicitly set 'maxNumComponents' to very high number, so that consolidation will not be triggered.

It does this because once you have a lot of buffers in a CompositeByteBuf accessing things on a specific index can for example become very slow.

If this is a problem for you or not depends highly on the use-case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM