OpenJDK 迁移后 hs_err 日志中的内存不足错误

问题描述

我们的服务器已经从 Oracle JDK 8 迁移到 OpenJDK 8。现在,同样的过程,我们遇到了分段错误。原因是 NULL 指针访问,它是由于 JVM 中的内存不足错误而发生的。 通过对hs_err日志的详细分析,我们发现这样的错误很频繁,以前从未发生过。它的32位进程和配置是:

/opt/jdk/bin/java -Dsystem.pmi=1 -Xss1024k -xms1024M -Xmx1024M -Djava.pmi.server.hostname=XX.XXX.Xx.xxx -classpath 
.:/home/lib/api/conf:/home/lib/adminjni.jar:/home/lib/springContext/*:/home/lib/epsapi/*:/home/lib/clientapi/*:/opt/tomcat/webapps/admin.jar:/opt/tomcat/lib/activation.jar:/opt/tomcat/lib/jsr173_api.jar com.client.aPIImpl 1100 32772

我可以找到频繁的 GC 周期。 hs_err 日志片段:

GC Heap History (10 events):
Event: 15614221.686 GC heap before
{Heap before GC invocations=21294 (full 6969):
 PSYoungGen      total 339456K,used 294065K [0xd2ac0000,0xe8000000,0xe8000000)
  eden space 329472K,87% used [0xd2ac0000,0xe45952d0,0xe6c80000)
  from space 9984K,44% used [0xe6c80000,0xe70d7380,0xe7640000)
  to   space 9472K,0% used [0xe76c0000,0xe76c0000,0xe8000000)
 ParOldGen       total 699136K,used 3234K [0xa8000000,0xd2ac0000,0xd2ac0000)
  object space 699136K,0% used [0xa8000000,0xa8328af8,0xd2ac0000)
 Metaspace       used 8642K,capacity 9017K,committed 9112K,reserved 9520K
Event: 15614221.690 GC heap after
Heap after GC invocations=21294 (full 6969):
 PSYoungGen      total 340224K,used 3617K [0xd2ac0000,0xe8000000)
  eden space 330752K,0% used [0xd2ac0000,0xe6dc0000)
  from space 9472K,38% used [0xe76c0000,0xe7a48630,0xe8000000)
  to   space 9216K,0% used [0xe6dc0000,0xe6dc0000,0xe76c0000)
 ParOldGen       total 699136K,reserved 9520K
}
Event: 15615126.890 GC heap before
{Heap before GC invocations=21295 (full 6969):
 PSYoungGen      total 340224K,used 334369K [0xd2ac0000,100% used [0xd2ac0000,reserved 9520K
Event: 15615126.897 GC heap after
Heap after GC invocations=21295 (full 6969):
 PSYoungGen      total 339968K,used 4789K [0xd2ac0000,0xe6dc0000)
  from space 9216K,51% used [0xe6dc0000,0xe726d600,0xe76c0000)
  to   space 8960K,0% used [0xe7740000,0xe7740000,reserved 9520K
}
Event: 15615421.185 GC heap before
{Heap before GC invocations=21296 (full 6969):
 PSYoungGen      total 339968K,used 329465K [0xd2ac0000,98% used [0xd2ac0000,0xe67d0f68,reserved 9520K
Event: 15615421.188 GC heap after
Heap after GC invocations=21296 (full 6969):
 PSYoungGen      total 340736K,used 3182K [0xd2ac0000,0xe8000000)
  eden space 331776K,0xe6ec0000)
  from space 8960K,35% used [0xe7740000,0xe7a5bb00,0xe8000000)
  to   space 8704K,0% used [0xe6ec0000,0xe6ec0000,0xe7740000)
 ParOldGen       total 699136K,reserved 9520K
}
Event: 15615422.838 GC heap before
{Heap before GC invocations=21297 (full 6969):
 PSYoungGen      total 340736K,used 55273K [0xd2ac0000,15% used [0xd2ac0000,0xd5d9e930,reserved 9520K
Event: 15615422.841 GC heap after
Heap after GC invocations=21297 (full 6969):
 PSYoungGen      total 340480K,used 1522K [0xd2ac0000,0xe6ec0000)
  from space 8704K,17% used [0xe6ec0000,0xe703c830,0xe7740000)
  to   space 8704K,0% used [0xe7780000,0xe7780000,reserved 9520K
}
Event: 15615422.841 GC heap before
{Heap before GC invocations=21298 (full 6970):
 PSYoungGen      total 340480K,reserved 9520K
Event: 15615422.868 GC heap after
Heap after GC invocations=21298 (full 6970):
 PSYoungGen      total 340480K,used 0K [0xd2ac0000,used 3585K [0xa8000000,0xa8380778,reserved 9520K
}

Deoptimization events (10 events):
Event: 9379207.189 Thread 0x51b52000 Uncommon trap: reason=unstable_if action=reinterpret pc=0xe8dd06ac method=java.util.HashMap.getNode(ILjava/lang/Object;)Ljava/util/HashMap$Node; @ 84
Event: 9379318.444 Thread 0x51b52000 Uncommon trap: reason=unstable_if action=reinterpret pc=0xe8cf46fc method=java.util.HashMap.getNode(ILjava/lang/Object;)Ljava/util/HashMap$Node; @ 84
Event: 9380005.745 Thread 0x4ede5800 Uncommon trap: reason=unstable_if action=reinterpret pc=0xe8d66138 method=java.util.HashMap.removeNode(ILjava/lang/Object;Ljava/lang/Object;ZZ)Ljava/util/HashMap$Node; @ 97
Event: 9380005.746 Thread 0x4ede5800 Uncommon trap: reason=unstable_if action=reinterpret pc=0xe8d0c054 method=java.util.HashMap.removeNode(ILjava/lang/Object;Ljava/lang/Object;ZZ)Ljava/util/HashMap$Node; @ 211
Event: 13144620.110 Thread 0x410fd800 Uncommon trap: reason=unloaded action=reinterpret pc=0xe8f5d8a8 method=sun.reflect.GeneratedMethodAccessor28.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; @ 312
Event: 13144620.110 Thread 0x410fd800 Uncommon trap: reason=unloaded action=reinterpret pc=0xe8b99f84 method=sun.rmi.server.UnicastServerRef.dispatch(Ljava/rmi/Remote;Ljava/rmi/server/RemoteCall;)V @ 239
Event: 13144620.113 Thread 0x410fd800 Uncommon trap: reason=unstable_if action=reinterpret pc=0xe8d4b6f4 method=java.lang.Throwable.getourStackTrace()[Ljava/lang/StackTraceElement; @ 7
Event: 13144620.114 Thread 0x410fd800 Uncommon trap: reason=unstable_if action=reinterpret pc=0xe8b8ac3c method=java.io.ObjectOutputStream$HandleTable.assign(Ljava/lang/Object;)I @ 24
Event: 13144620.121 Thread 0x410fd800 Uncommon trap: reason=unstable_if action=reinterpret pc=0xe8c28dec method=java.lang.Throwable.getourStackTrace()[Ljava/lang/StackTraceElement; @ 7
Event: 13144620.121 Thread 0x410fd800 Uncommon trap: reason=unstable_if action=reinterpret pc=0xe8b9f1ec method=java.io.ObjectOutputStream$HandleTable.assign(Ljava/lang/Object;)I @ 24

Classes redefined (0 events):
No events

Internal exceptions (10 events):
Event: /.209 Thread 0xfec32800 Exception <a 'java/lang/OutOfMemoryError'> (0xdf4599f0) thrown at [/builddir/build/BUILD/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.i386/openjdk/hotspot/src/share/vm/prims/jni.cpp,line 735]
Event: 15614221.458 Thread 0xfec32800 Exception <a 'java/lang/OutOfMemoryError'> (0xe1cbade0) thrown at [/builddir/build/BUILD/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.i386/openjdk/hotspot/src/share/vm/prims/jni.cpp,line 735]
Event: 15614221.705 Thread 0xfec32800 Exception <a 'java/lang/OutOfMemoryError'> (0xd539f200) thrown at [/builddir/build/BUILD/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.i386/openjdk/hotspot/src/share/vm/prims/jni.cpp,line 735]
Event: 15614221.959 Thread 0xfec32800 Exception <a 'java/lang/OutOfMemoryError'> (0xd5406b78) thrown at [/builddir/build/BUILD/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.i386/openjdk/hotspot/src/share/vm/prims/jni.cpp,line 735]
Event: 15615419.879 Thread 0x03d5a000 Exception <a 'java/lang/OutOfMemoryError'> (0xd7f991f8) thrown at [/builddir/build/BUILD/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.i386/openjdk/hotspot/src/share/vm/prims/jni.cpp,line 735]
Event: 15615420.144 Thread 0x03d5a000 Exception <a 'java/lang/OutOfMemoryError'> (0xdadf68a8) thrown at [/builddir/build/BUILD/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.i386/openjdk/hotspot/src/share/vm/prims/jni.cpp,line 735]
Event: 15615420.411 Thread 0x03d5a000 Exception <a 'java/lang/OutOfMemoryError'> (0xddc44638) thrown at [/builddir/build/BUILD/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.i386/openjdk/hotspot/src/share/vm/prims/jni.cpp,line 735]
Event: 15615420.666 Thread 0x03d5a000 Exception <a 'java/lang/OutOfMemoryError'> (0xe0aa21d8) thrown at [/builddir/build/BUILD/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.i386/openjdk/hotspot/src/share/vm/prims/jni.cpp,line 735]
Event: 15615420.924 Thread 0x03d5a000 Exception <a 'java/lang/OutOfMemoryError'> (0xe38eeb58) thrown at [/builddir/build/BUILD/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.i386/openjdk/hotspot/src/share/vm/prims/jni.cpp,line 735]
Event: 15615421.205 Thread 0x03d5a000 Exception <a 'java/lang/OutOfMemoryError'> (0xd58a9038) thrown at [/builddir/build/BUILD/java-1.8.0-openjdk-1.8.0.171-8.b10.el6_9.i386/openjdk/hotspot/src/share/vm/prims/jni.cpp,line 735]

Events (10 events):
Event: 15615679.282 Thread 0xf986dc00 Thread added: 0xf986dc00
Event: 15615741.561 Thread 0xfc554400 Thread exited: 0xfc554400
Event: 15615753.924 Thread 0x03d92400 Thread exited: 0x03d92400
Event: 15615765.803 Thread 0x13782800 Thread exited: 0x13782800
Event: 15615797.614 Thread 0xfc554400 Thread added: 0xfc554400
Event: 15615809.165 Thread 0x03d92400 Thread added: 0x03d92400
Event: 15615871.043 Thread 0xf98e6800 Thread exited: 0xf98e6800
Event: 15615906.056 Thread 0xf98e6800 Thread added: 0xf98e6800
Event: 15615966.431 Thread 0xfecff800 Thread exited: 0xfecff800
Event: 15615980.812 Thread 0x13782800 Thread added: 0x13782800

如果我遗漏了什么,请提出建议。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)