接口ByteBufAllocator中定义了一个默认的ByteBufAllocator DEFAULT =
ByteBufUtil.DEFAULT_ALLOCATOR,跟进去:
static final ByteBufAllocator DEFAULT_ALLOCATOR;
static {
//非安卓返回pooled
String allocType = SystemPropertyUtil.get(
"io.netty.allocator.type", PlatformDependent.isAndroid() ? "unpooled" : "pooled");
allocType = allocType.toLowerCase(Locale.US).trim();
ByteBufAllocator alloc;
if ("unpooled".equals(allocType)) {
alloc = UnpooledByteBufAllocator.DEFAULT;
} else if ("pooled".equals(allocType)) {
//到这里
alloc = PooledByteBufAllocator.DEFAULT;
} else {
alloc = PooledByteBufAllocator.DEFAULT;
}
//定义DEFAULT_ALLOCATOR = PooledByteBufAllocator.DEFAULT; 跟进去
DEFAULT_ALLOCATOR = alloc;
在这里 ByteBufAllocator DEFAULT =
版权声明:本文为AnY11原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。