在DefaultChannelConfig中,
而ByteBuffAllocator中定义的DEFAULT如下:
ByteBufUtil类中
首先获取io.netty.allocator.type(可按下图配置)
看是pooled还是unpooled,如果没有,则判断是否是安卓平台,是的话取unpooled,否则取pooled.
最终会返回UnpooledByteBufAllocator.DEFAULT或者PooledByteBufAllocator.DEFAULT.
然后它们再根据相关配置决定返回DirectByteBuf还是HeapByteBuf
而使用DirectByteBuf还是HeapByteBuf由如下逻辑确定:
也就是默认使用DirectByteBuf,如果设置了io.netty.noPreferDirect参数,则以这个参数为准,如果设置为true,则会使用HeapByteBuf