The garbage collection (GC) algorithms in Java provide opportunities for performance optimizations for your application. Java provides the following GC algorithms:

  • Serial GC. This algorithm is typically used in client-style applications that don't require low pause times. Specify -XX:+UseSerialGC to use this algorithm.
  • Parallel GC, which is optimized to maximize throughput. Specify -XX:+UseParNewGC to use this algorithm.
  • Mostly-Concurrent or Concurrent Mark-Sweep GC, which is optimized to minimize latency. Specify -XX:+UseConcMarkSweepGC to use this algorithm.
  • Garbage First GC, a new GC algorithm intended to replace Concurrent Mark-Sweep GC. Specify -XX:+UseG1GC to use this algorithm.

Consider testing your application with different GC algorithms to determine their effects on performance.

Flags for GC Debugging

Set the following flags in Java to log the GC algorithm's behavior for later analysis:


For more information, see the Java Garbage Collection Tuning document or the Java Garbage Collection links.