JAVA GC重大GC对比次要GC [英] JAVA GC Major GC vs Minor GC

查看:61
本文介绍了JAVA GC重大GC对比次要GC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在对延迟敏感的应用程序中,我们具有缓存数据(驻留在TG中)和寿命短的对象,这些对象在YG中消失了.我已经看到次要GC时间和主要GC时间之间存在显着差异.我怀疑这与相对较大的TG大小有关.谁能解释一下GC时间与TG大小之间的关系.次要GC非常频繁且快速.

In our latency sensitive app we have caching data (which resides in TG) and short lived object which die out in the YG. I have seen there is significant difference in the minor GC time and Major GC time. I suspected that it is related to relatively larger size of TG. Could anyone explain how the GC time correlates with the TG size. Minor GC is quite frequent and fast.

推荐答案

可以在YG中进行少量收集的对象转移到TG/Old Generation,以释放YG中的空间. YG的大小保持较小,以确保次要收集不会花费太多时间,并且可以更频繁地运行.在这些仍具有引用的次要GC对象期间,将其移至TG.

Objects which survive minor collection in YG gets moved to TG/Old generation to free up space in YG. Size of YG is kept small to ensure that minor collection doesn't take much time and can be run more frequently. And during these minor GC objects which still have references are moved to TG.

因此TG的大小更大,因为通常在几乎没有YG清理的情况下,较大的对象就会移到该段.另外,TG中的清理操作不是很频繁,因此可以分配更大的内存.

So TG size is more because usually bigger objects which survive few YG cleanups move to this segment. Also cleanup in TG doesn't run very frequently so it can have bigger memory allocated.

因此,次要GC会清理YG中的对象,但主要GC会清理YG和TG.

So minor GC cleans up objects in YG but major GC cleans up YG as well as TG.

这篇关于JAVA GC重大GC对比次要GC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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