Reputation: 320
So there are 2 types of Garbage Collection process JVM does: Minor GC and Major GC. And different types of Garbage Collectors are there : Serial, Parallel, CMS, G1C etc. And these Garbage collectors does the garbage collection process differently according to different algorithms they implement.
As per Oracle documentation of CMS,
Minor collections can interleave with an ongoing major cycle, and are done in a manner similar to the parallel collector (in particular, the application threads are stopped during minor collections).
Does this means that all the Garbage collectors characterizes and controls Major GC only? In other words, is the behavior of Minor GC same regardless of the Garbage Collector chosen?
Upvotes: 4
Views: 241
Reputation: 3392
Most GC designs use a generational heap (Shenandoah is an exception to that). The typical heap is divided into young and old generations that reflect how long an object has been in use. A minor GC occurs when the young generation requires collection and a major GC when the old gen. does.
How this works is entirely dependent on the algorithms being used. Often, different collection algorithms are used for different generations. This makes a lot of sense because objects in the young generation will be promoted (i.e. removed) during GC, whereas objects in the old gen. must stay there. How the respective algorithms work may lend a design to being able to overlap the collection of the young and old generations, but this is not a necessity.
The C4 algorithm, used in the Zing JVM from Azul (who I work for) uses a generational heap but the same algorithm for both young and old. C4 is fully concurrent, meaning application threads continue to run whilst GC occurs. The weak generational hypothesis (most objects will only be used for a very short time) makes this design more efficient.
To answer your specific question, the behaviour of the minor GC is not the same regardless of which garbage collector is chosen.
Upvotes: 2
Reputation: 43052
Collectors are implementation details of JVMs, the following only covers Oracle/OpenJDK Hotspot:
Recent collectors such as G1, ZGC, Shenandoah are highly integrated where all GC cycles (major/minor would be oversimplifying things here) are managed by code specific to that collector.
Some of the older collectors on the other hand are more modular and allow you to mix and match to some extent. Jon Masamitsu's blog post Our Collectors gives an overview of pre-G1 collectors. Note that some of those have been deprecated in jdk8 and removed in jdk9
Upvotes: 2