Java 8元数据空间垃圾收集 [英] Java 8 metaspace garbage collection

查看:972
本文介绍了Java 8元数据空间垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行的java进程在第一个小时内运行良好,或者运行得很好。但是,性能会迅速降低。在分析时,我发现metaspace垃圾收集发生得非常频繁,直到小时标记,然后失控:



我确信我可以使用-XX:MaxMetaspaceSize选项修复此问题。不过,我想了解更多关于这种行为可能发生的原因。我无法想象垃圾收集算法为什么会像这样。有没有人有更好的解决方案的解释或建议?谢谢

解决方案

您可以尝试设置 -XX:MaxMetaspaceExpansion = 0 。这应该强制一个完整的GC - 释放动态创建的方法/类数据 - 在尝试扩展元组空间之前。此外,您可以尝试将 MaxMetaspaceFreeRatio 设置为比默认值更低的值,以在GC之后缩小元数据空间本身。



有关其他元数据相关选项,请参见此答案



Metaspace集合本身依赖于被垃圾收集器卸载的类。因此,根据您使用GC调整垃圾回收时间可能会有所帮助。


A java process that I'm running performs consistently well in the first hour or so that it runs. However, performance then rapidly degrades. When profiling I found that the metaspace garbage collection happened fairly frequently until the hour mark and then got out of control:

I'm fairly sure I'll be able to fix this using the -XX:MaxMetaspaceSize option. However, I'd like to know more about why this behaviour might be occurring. I can't imagine why the garbage collection algorithm would behave like this. Does anyone have an explanation or advice about a better fix? Thanks

解决方案

You can try setting -XX:MaxMetaspaceExpansion=0. This should force a full GC - releasing dynamically created methods/class data - before attempting to grow the metaspace. Additionally you can try setting MaxMetaspaceFreeRatio to a lower value than the default to shrink the metaspace itself more after a GC.

See this answer for other metaspace related options.

Metaspace collection itself relies on classes being unloaded by the garbage collector. So depending on the GC you're using tweaking that to reclaim garbage sooner might also help.

这篇关于Java 8元数据空间垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆