接口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 =

本文详细介绍了Netty中PooledByteBufAllocator的初始化过程,包括PoolThreadCache、PoolArena、PoolChunk、PoolSubpage的初始化,并探讨了PooledByteBuf的分配和回收机制,涉及微小型、小型和普通型PooledByteBuf的分配,以及PoolChunkList和Recycler的相关源码解析。
最低0.47元/天 解锁文章

244

被折叠的 条评论
为什么被折叠?



