是什么导致物体从年轻一代转移到老一代 [英] What cause Objects to move from Young Generation to Old Generation

查看:115
本文介绍了是什么导致物体从年轻一代转移到老一代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过多次GC循环后,年轻一代中幸存的对象将移至旧一代内存空间.

After many cycles of GC, Objects that are survived in young generation are moved to the Old generation memory space.

请澄清,次要GC对此负责吗?还是专业GC?

Please clarify, Minor GC is responsible for this ? or Major GC?

推荐答案

可以在Minor GC(年轻空间)或Full GC(所有空间)中将对象从年轻空间移至终身空间.主要GC收集仅在使用权空间中收集.

Objects can be moved from young to tenured space in either a Minor GC (young space) or Full GC (everything). A Major GC collection only collects in the tenured space.

在伊甸园空间中创建较小的对象,例如大型物件.租用空间中的数组.

Smaller objects are created in the Eden space, Large obejcts e.g. arrays in the tenured space.

清除Eden空间后,将幸存的对象复制到幸存者空间.它们会在两个幸存者空间之间来回复制,直到它们的年龄(复制的次数)达到使用期限阈值为止,在这种情况下,它将被复制到使用期限的空间中.

When the Eden space is cleared out, surviving objects are copied to the survivors spaces. They are copied back and forth between the two survivors spaces until their age (number of times copied) reaches the tenuring threshold and in which case it is copied to the tenured space.

如果在伊甸园空间中有太多对象无法复制到幸存者空间,则会触发完整的GC,所有活动对象都将直接进入保管空间.

If there is too many objects in the Eden space to be copied to the survivor spaces, a full GC is triggered and all live object go straight to the tenured space.

考虑大小(survivorRatio),幸存者大小将始终大于eden

Considering the size (survivorRatio) survivor size will always be greater than eden

幸存者比率是幸存者空间比伊甸园空间小多少倍.例如-XX:SurvivorRatio=8表示幸存者空间是年轻一代的1/10.有两个幸存者空间(每个1/10),而伊甸园空间则大8倍(8/10)

The survivor ratio is how much smaller the survivor space is than the Eden space. e.g. -XX:SurvivorRatio=8 means the survivors space is 1/10th of young generation. There is two survivors spaces (1/10th each) and the Eden space is 8 times larger (8/10ths)

即使幸存者的空间大于伊甸园,重要的还是幸存者的自由空间.例如,您可能拥有90%的幸存者空间(因为它仍然具有来自最后N个集合的对象)

Even if the survivors space was larger than the Eden, it's the amount of free space in the survivor which matters. You could have a survivor space which is 90% full for example (as it still has objects from the last N collections)

那么,如果对象的尺寸较小(不是巨大的),那么是否存在将对象直接从eden复制到Old的情况?

So will there be ever a scenario to have that objects directly gets copied from eden to Old if objects are smaller in size (not humongous) ?

如果您将幸存者空间减小到足以触发每次完整收集的程度,则对象将从伊甸园"转移到终身保育".我不建议这样做.

If you make the survivor spaces small enough to trigger a full collection each time, the objects will go from Eden to Tenured. I don't recommend going this.

这篇关于是什么导致物体从年轻一代转移到老一代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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