问题描述
我一直在为我的应用程序进行压力测试。在我的分析中,我确实在堆直方图中发现了一些 OutOfMemory 实例。
726: 10 320 java.lang.OutOfMemoryError
我没有在我的应用程序日志中观察到 OutOfMemory 问题,也没有在线程堆栈中观察到。这说明什么?我的应用程序是否遇到了 10 次 OOM?
应用程序启动命令
命令行标志:-XX:-BytecodeVerificationLocal -XX:-BytecodeVerificationRemote -XX:+FlightRecorder -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/pmc/oom.hprof -XX:InitialHeapSize=134217728 -XX :+ManagementServer -XX:MaxHeapSize=805306368 -XX:NewRatio=1 -XX:+PrintClassHistogram -XX:-PrintConcurrentLocks -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UnlockCommercialFeatures -XX:+UseCompressedClasspointers -XX:+UseCompressedOops -XX:+UseParallelGC
解决方法
我认为您的应用没有遇到 OutOfMemoryError
10 次。看起来虚拟机正在自己创建它。我关注了 Javadoc,但仍然不确定它的实际需要。
我运行了一个程序并对它进行了堆转储并看到了同样的事情:
Class Name | Shallow Heap | Retained Heap
----------------------------------------------------------------------------------------------------------------------------------------------
java.lang.OutOfMemoryError @ 0x8001a590 | 32 | 520
java.lang.OutOfMemoryError @ 0x8001a388 | 32 | 520
java.lang.OutOfMemoryError @ 0x8001a180 | 32 | 520
java.lang.OutOfMemoryError @ 0x80019f78 | 32 | 520
java.lang.OutOfMemoryError @ 0x80001760 JNI Global | 32 | 200
|- detailMessage java.lang.String @ 0x8001a798 Java heap space: failed reallocation of scalar replaced objects| 24 | 168
|- <class> class java.lang.OutOfMemoryError @ 0x800299d0 System Class | 8 | 8
'- Total: 2 entries | |
java.lang.OutOfMemoryError @ 0x80001740 JNI Global | 32 | 128
|- detailMessage java.lang.String @ 0x8001a840 GC overhead limit exceeded | 24 | 96
|- <class> class java.lang.OutOfMemoryError @ 0x800299d0 System Class | 8 | 8
'- Total: 2 entries | |
java.lang.OutOfMemoryError @ 0x80001720 JNI Global | 32 | 152
|- detailMessage java.lang.String @ 0x8001a8a0 Requested array size exceeds VM limit | 24 | 120
|- <class> class java.lang.OutOfMemoryError @ 0x800299d0 System Class | 8 | 8
'- Total: 2 entries | |
java.lang.OutOfMemoryError @ 0x80001700 JNI Global | 32 | 120
|- detailMessage java.lang.String @ 0x8001a918 Compressed class space | 24 | 88
|- <class> class java.lang.OutOfMemoryError @ 0x800299d0 System Class | 8 | 8
'- Total: 2 entries | |
java.lang.OutOfMemoryError @ 0x800016e0 JNI Global | 32 | 96
|- detailMessage java.lang.String @ 0x8001a970 Metaspace | 24 | 64
|- <class> class java.lang.OutOfMemoryError @ 0x800299d0 System Class | 8 | 8
'- Total: 2 entries | |
java.lang.OutOfMemoryError @ 0x800016c0 JNI Global | 32 | 104
|- detailMessage java.lang.String @ 0x8001a9b0 Java heap space | 24 | 72
|- <class> class java.lang.OutOfMemoryError @ 0x800299d0 System Class | 8 | 8
'- Total: 2 entries | |
Total: 10 entries | |
----------------------------------------------------------------------------------------------------------------------------------------------
如果您在 STDOUT/STDERR 中没有看到任何 OutOfMemoryError
的痕迹,或者没有在 -XX:HeapDumpPath=/home/pmc
位置生成任何堆转储,那么您很好。