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.
1

There are 1 best solutions below

0
On

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.