Search code examples
javamonogarbage-collectiong1gc

What are the main differences between G1GC and SGen GC


What are the main differences between Java7's G1 garbage collector and mono's SGen garbage collector? I know both of them are of generational GC, but how are they different in performance wise and architecture wise?


Solution

  • First, lets review both GC collectors:

    The Working with SGen defines that SGen is a generation collector that implements two GC algorithms for its Major Heap : (i) copying collector and (ii) mark-and-sweep.

    Thereofre, although both SGEn and G1 are generational, fundamental difference is that G1 generations are split into many blocks of the same size while SGen applies a more traditional approach - one generation is represented as one continuous space.

    Further, SGen's copying collector is by nature compacting. On the other hand, the Mark-And-Sweep algorithm is similar to the Java's CMS collector. And thus you can ask yourself, what is the difference between CMS and G1. There is a lot of information out there about their differences.