本文介绍了垃圾收集问题在年轻一代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当伊甸园空间年轻一代满时,小GC会触发。而在小型GC过程中,伊甸园的非自由物品和一个来源幸存者的空间将被复制到另一个目的地幸存者的空间。我的问题是,如果目的地幸存者空间已满,小型GC如何处理?

解决方案

如果无法完成/完成次要集合,主要/完整收集被执行。这通常是使用mark-sweep-compact算法而不是复制算法来完成的......这是完整收集成本昂贵的一个原因。但最终(如果你保留填满堆)一个完整的集合将无法回收足够的空间来继续和OOME将被抛出。 (或者,如果您使用的是 -XX:+ UseGCOverheadLimit ,那么当在GC中花费的时间百分比超过指定的阈值时,将引发OOME。)

When Eden space is young generation is full, minor GC will be triggered. And in the minor GC process, non-free objects in Eden and one source Survivor space will be copied to another destination Survivor space.

My question is, if the destination Survivor space is full, how could minor GC handle?

解决方案

If it is not possible to do / complete a minor collection, then a major / full collection is performed. This is typically done using a mark-sweep-compact algorithm rather than copying algorithm ... which is one reason why full collection is expensive.

But ultimately (if you keep filling the heap) a full collection will not be able to reclaim enough space to continue and an OOME will be thrown. (Or if you are using -XX:+UseGCOverheadLimit, the OOME will be thrown when the percentage time spent in GC exceeds a designated threshold.)

这篇关于垃圾收集问题在年轻一代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 08:12