据我理解:
Minor GC
在 young gen 中发生的 GC 通常称为 Minor GC,因为 live-set 通常很小(我是指典型的 Java 应用程序,考虑到弱代假说),并且使用较少数量的对象进行复制和重映射的收集器需要 较短 的时间来完成。
Major GC
在 old gen 中发生的 GC 通常称为 Major GC,因为 live-set 通常很大(与 young gen 相比),它通常会压缩 old gen,并且随着 old generation 大小的线性增加,整理所需的时间也会相应增加。
不幸的是,GC 日志将 old generation 收集报告为 Full GC,但在 Java 内存管理白皮书中,全堆 GC 指整个堆都被收集。
A Full GC will be triggered whenever the heap fills up. In such a case the
young generation is collected first followed by the old generation. If the
old generation is too full to accept the content of the young generation,
the young generation GC is omitted and the old generation GC is used to
collect the full heap, either in parallel or serial. Either way the whole
heap is collected with a stop-the-world event.
如果年轻代填满时总是会发生 Minor GC,老年代填满时总是会发生 Major GC,那么所谓的 Full GC 会在什么时候发生呢?如果年轻代和老年代收集器都在做其工作,为什么堆还会变满呢?