在 Netty 中使用直接分配时,字节的堆分配会增加

Heap allocations for bytes increase while using a direct allocation in Netty

根据我对使用直接分配 API 的理解,不应在堆上分配内存,但我仍然看到 byte[]

使用了大量内存

这是我分配的方式


channelContext.alloc().directBuffer()

Visual VM 堆转储

您在此处看到的 byte[] 分配被 PoolChunk 用作内部数据结构。每个块只有一次 byte[] 分配。