我正在尝试调试具有高内存使用率的 Java 应用程序。使用 native 内存跟踪,我发现名为“其他”的部分使用了大量内存。我似乎无法在网上找到任何关于可能存储在这里的内容、可能导致它高的原因或如何进一步调试的信息。任何沿着这些路线的帮助将不胜感激。作为引用,这是我从 jcmd 得到的输出:
Total: reserved=49GB, committed=48GB
- Java Heap (reserved=32GB, committed=32GB)
(mmap: reserved=32GB, committed=32GB)
- Thread (reserved=1GB, committed=0GB)
(thread #1291)
(stack: reserved=1GB, committed=0GB)
- GC (reserved=2GB, committed=2GB)
(mmap: reserved=1GB, committed=1GB)
- Other (reserved=14GB, committed=14GB)
(malloc=14GB #1520)
最佳答案
Other
NMT 报告的一部分通过 Direct ByteBuffers 计算应用程序分配的堆外内存或立即通过 Unsafe.allocateMemory
. ByteBuffer.allocateDirect
电话Unsafe.allocateMemory
在引擎盖下。
您可以通过 JMX 监控 Direct ByteBuffers 的数量和它们占用的总内存 - 查找 BufferPool MBean:
Async-profiler可以帮助找到堆外内存的分配位置。跑
profiler.sh -d <duration> -e jdk.internal.misc.Unsafe.allocateMemory -f profile.html <pid>
这将创建一个火焰图,显示所有位置的堆栈跟踪 Unsafe.allocateMemory
(包括 ByteBuffer.allocateDirect
)来自:有关 ByteBuffers 及其与堆外内存使用的关系的更多信息,请参阅 this presentation .
关于java - java 的 native 内存跟踪输出的 "other"部分有什么内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65157496/