Gre*_*reg 4 java memory performance jvm java-11
我正在尝试调试具有高内存使用率的 Java 应用程序。使用本机内存跟踪,我发现名为“其他”的部分使用了大量内存。我似乎无法在网上找到任何关于可能存储在这里的内容、可能导致它高的原因或如何进一步调试的信息。任何沿着这些路线的帮助将不胜感激。作为参考,这是我从 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)
Run Code Online (Sandbox Code Playgroud)
OtherNMT 报告的一部分计算应用程序通过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>
Run Code Online (Sandbox Code Playgroud)
这将创建一个火焰图,显示调用Unsafe.allocateMemory(包括ByteBuffer.allocateDirect)的所有位置的堆栈跟踪:
有关 ByteBuffers 及其与堆外内存使用的关系的更多信息,请参阅此演示文稿。