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:+UseSerialGCto use this algorithm.
- Parallel GC, which is optimized to maximize throughput. Specify
-XX:+UseParNewGCto use this algorithm.
- Mostly-Concurrent or Concurrent Mark-Sweep GC, which is optimized to minimize latency. Specify
-XX:+UseConcMarkSweepGCto use this algorithm.
- Garbage First GC, a new GC algorithm intended to replace Concurrent Mark-Sweep GC. Specify
-XX:+UseG1GCto 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: