java.lang.OutOfMemoryError: Metaspace
近日做系统迁移,迁移完成后系统CPU持续负载报警,经查看日志中存在多条java.lang.OutOfMemoryError: Metaspace错误信息,具体日志如下:
Caused by: java.lang.InternalError: BMH.reinvoke=Lambda(a0:L/SpeciesData<L>,a1:L)=>{
t2:L=MethodHandleImpl.array(a1:L);
t3:L=Species_L.argL0(a0:L);
t4:L=MethodHandle.invokeBasic(t3:L,t
2:L);t4:L}
at java.lang.invoke.MethodHandleStatics.newInternalError(MethodHandleStatics.java:127) ~[?:1.8.0_60]
at java.lang.invoke.LambdaForm.compileToBytecode(LambdaForm.java:660) ~[?:1.8.0_60]
at java.lang.invoke.LambdaForm.prepare(LambdaForm.java:635) ~[?:1.8.0_60]
at java.lang.invoke.MethodHandle.<init>(MethodHandle.java:461) ~[?:1.8.0_60]
at java.lang.invoke.BoundMethodHandle.<init>(BoundMethodHandle.java:56) ~[?:1.8.0_60]
at java.lang.invoke.BoundMethodHandle$Species_L.<init>(BoundMethodHandle.java:209) ~[?:1.8.0_60]
at java.lang.invoke.BoundMethodHandle$Species_L.copyWith(BoundMethodHandle.java:226) ~[?:1.8.0_60]
at java.lang.invoke.MethodHandle.asCollector(MethodHandle.java:1002) ~[?:1.8.0_60]
at java.lang.invoke.MethodHandleImpl$AsVarargsCollector.asTypeUncached(MethodHandleImpl.java:502) ~[?:1.8.0_60]
at java.lang.invoke.MethodHandle.asType(MethodHandle.java:761) ~[?:1.8.0_60]
at java.lang.invoke.CallSite.makeUninitializedCallSite(CallSite.java:241) ~[?:1.8.0_60]
at java.lang.invoke.CallSite.<init>(CallSite.java:105) ~[?:1.8.0_60]
at java.lang.invoke.MutableCallSite.<init>(MutableCallSite.java:100) ~[?:1.8.0_60]
at jdk.internal.dynalink.support.AbstractRelinkableCallSite.<init>(AbstractRelinkableCallSite.java:104) ~[nashorn.jar:?]
at jdk.internal.dynalink.ChainedCallSite.<init>(ChainedCallSite.java:135) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.LinkerCallSite.<init>(LinkerCallSite.java:71) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.LinkerCallSite.newLinkerCallSite(LinkerCallSite.java:123) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.Bootstrap.bootstrap(Bootstrap.java:207) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.Bootstrap.createDynamicInvoker(Bootstrap.java:388) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.Bootstrap.createDynamicInvoker(Bootstrap.java:362) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.InvokeByName.<init>(InvokeByName.java:86) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.InvokeByName.<init>(InvokeByName.java:73) ~[nashorn.jar:?]
at jdk.nashorn.internal.objects.Global.<init>(Global.java:93) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.Context.newGlobal(Context.java:1102) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine$2.run(NashornScriptEngine.java:347) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine$2.run(NashornScriptEngine.java:343) ~[nashorn.jar:?]
at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_60]
at jdk.nashorn.api.scripting.NashornScriptEngine.createNashornGlobal(NashornScriptEngine.java:343) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.<init>(NashornScriptEngine.java:143) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngineFactory.getScriptEngine(NashornScriptEngineFactory.java:148) ~[nashorn.jar:?]
at javax.script.ScriptEngineManager.getEngineByName(ScriptEngineManager.java:238) ~[?:1.8.0_60]
Caused by: java.lang.OutOfMemoryError: Metaspace
一筹莫展之际注意到JDK版本为1.8.0_60,而正常镜像中的JDK版本均为1.8.0_192,因此怀疑是不是JDK版本出了问题,然后重新打包编译、构建镜像上线后问题解决。
后经查证JDK1.8.0_60版本确实存在类似bug,附链接如下: https://bugs.openjdk.java.net/browse/JDK-8066991 https://bugs.openjdk.java.net/browse/JDK-8129124 总结: 通过升级JDK版本解决此问题,在做系统迁移时应做好checklist,最好能结对迁移,不然不知道哪里就采坑啦!
|