简体   繁体   English

G1 GC 中的 Full GC 与 Major GC

[英]Full GC vs Major GC in G1 GC

I have just started learning about G1 GC.我刚刚开始学习 G1 GC。 This is in continuation with my other question: Full GC in G1 GC这是我的另一个问题的延续: G1 GC中的Full GC

I came across an article saying full gc and major gc (old gen collection) are two different things and that full gc is single threaded.我看到一篇文章说full gc 和major gc (old gen collection) 是两个不同的东西,full gc 是单线程的。 I am confused regarding this.我对此感到困惑。 If both are two differnt things then how does full gc collect garbage ie which algorithm or phases or steps are perfomed during full gc in G1 GC.如果两者都是不同的东西,那么完整 gc 如何收集垃圾,即在 G1 GC 中的完整 gc 期间执行哪些算法或阶段或步骤。

In the case of G1, there is a way that these two could be differentiated (this does not apply to all GC algorithms).在 G1 的情况下,有一种方法可以区分这两者(这并不适用于所有 GC 算法)。

G1 uses regions for the heap (typically 1Mb in size). G1 使用堆区域(通常大小为 1Mb)。 These areas of memory are grouped together to form the young and old generations as separate logical areas. memory 的这些区域组合在一起,将年轻代和老年代形成为单独的逻辑区域。 For an old gen collection, G1 will attempt to reclaim enough space by simply reclaiming regions that no longer have any live data (very cheap), or copy live data from sparsely populated regions to empty regions (thus maximising how much live data is in that region).对于老一代的集合,G1 将尝试通过简单地回收不再有任何实时数据的区域(非常便宜)来回收足够的空间,或者将实时数据从人口稀少的区域复制到空区域(从而最大化该区域的实时数据量)地区)。

However, if G1 cannot reclaim enough space in this way it must fall back to a full compacting collection.但是,如果 G1 不能以这种方式回收足够的空间,它必须回退到一个完整的压缩集合。

This would explain how there is a distinction between major collection and full GC.这将解释主要收集和完整 GC 之间的区别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM