code: protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, @SuppressWarnings("unused") I msg,
                                 boolean preferDirect) throws Exception {
          if (preferDirect) {
              return ctx.alloc().ioBuffer();
          } else {
              return ctx.alloc().heapBuffer();
          }
      }
docs: Allocate a {@link ByteBuf} which will be used as argument of {@link #encode(ChannelHandlerContext, I, ByteBuf)}.
  Sub-classes may override this method to return {@link ByteBuf} with a perfect matching {@code initialCapacity}.