java8元数据区,Java 8元数据空间垃圾收集

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:

p3gcG.png

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值