Sobes.tech
Senior

What specific implementation of GC did you use?

sobes.tech AI

Answer from AI

In Java, multiple garbage collection (GC) implementations are often used, with the choice depending on latency and throughput requirements.

One popular implementation is G1 (Garbage-First) GC, which is optimized for multi-processor systems and large heaps, providing predictable pauses and good performance.

Other options include:

  • CMS (Concurrent Mark Sweep) — to minimize pauses but with higher fragmentation.
  • ZGC and Shenandoah — modern low-latency GCs that minimize pauses to milliseconds.

The specific implementation choice depends on the scenario: for example, server applications with high responsiveness requirements often choose G1 or ZGC.

Example of running with G1 GC:

java -XX:+UseG1GC -jar app.jar