版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yangguosb/article/details/86716608
现象
应用刚启动的几分钟内固定的发生3次FGC,之后平稳不再GC;
GC日志分析
从GC日志可以看出,Metaspace容量达到上限分别触发了一次YGC和FGC,而且Metaspace容量的容量在变大这说明Metaspace容量在不断扩容,这说明Metaspace容量设置过小导致应用启动时发生了扩容,查看JVM参数发现没有显式指定Metaspace容量,默认为20M;
GCeasy可视化分析
GCeasy的分析结果如下,可以看出Metadata GC耗时严重,给出的修改建议也是-XX:MetaspaceSize配置Metaspace容量;
名词解释
- Metadata GC Threshold:This GC is triggered when Metaspace got filled up and JVM wants to create new objects in this space(Metaspace的容量达到设定的阈值,导致触发GC);
- Allocation Failure:Allocation Failure happens when there isn’t enough free space to create new objects in Young generation. Allocation failures triggers Young GC. On Linux, the JVM can trigger a GC if the kernel notifies there isn’t much memory left via mem_notify(Young区空间不足导致对象分配失败触发YGC);
参考: