简体   繁体   中英

Full GC vs Major GC in G1 GC

I have just started learning about G1 GC. This is in continuation with my other question: Full GC in G1 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. 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.

In the case of G1, there is a way that these two could be differentiated (this does not apply to all GC algorithms).

G1 uses regions for the heap (typically 1Mb in size). These areas of memory are grouped together to form the young and old generations as separate logical areas. 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).

However, if G1 cannot reclaim enough space in this way it must fall back to a full compacting collection.

This would explain how there is a distinction between major collection and full GC.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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