Does Java Garbage Collect always has to "Stop-the-World"?
<p>I am trying to understand Java's garbage collection more deeply.</p>

<p>In HotSpot JVM generational collection, in the heap, there are three areas (Young generation, Old generation and permanent generation). Also, there are two kinds of algorithms:</p>

<p>1) <strong>Mark Sweep Compact</strong>.</p>

<p>2) <strong>Concurrent Mark and Sweep</strong>.</p>

<p>Is that true whether GC needs "Stop-the-world" depends on the algorithm it uses rather than which generation it operates on? In another word, if I use 1) as GC algorithm on all three areas, STW will always happen ?</p>

<p>Also, I understand the difference is the second GC algorithm doesn't require Compaction which will result in fragmentation eventually. So the second question comes to why the compaction needs a STW pause?</p>