【问题标题】:Heap allocations for bytes increase while using a direct allocation in Netty在 Netty 中使用直接分配时,字节的堆分配会增加
【发布时间】:2020-10-22 13:58:57
【问题描述】:

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

这是我的分配方式


channelContext.alloc().directBuffer()

可视 VM 堆转储

【问题讨论】:

  • 你能说明这些 byte[] 是从哪里引用的吗?
  • @NormanMaurer 更新了截图。
  • @NormanMaurer 上图清晰吗?这可能是一个错误吗?

标签: memory memory-leaks netty


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-27
    • 1970-01-01
    • 1970-01-01
    • 2017-03-08
    • 2018-01-29
    • 2018-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多