Tune the performance of the Java garbage collector
Introduction
Overview
Setup
Types of Garbage Collector
Example Application
Basic GC Tuning Options
Intermediate GC Tuning Options
Next Steps
Tune the performance of the Java garbage collector
Review frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
Install Java using the
Arm Java install guide
. After installation, run
java --version to confirm it’s available.Run
java --version and review the reported release. Use one of the latest LTS JDKs because newer releases include GC improvements, such as G1GC pause time improvements from JDK 8 to JDK 11.Run
jstat -gcutil $(pgrep java) 1000 in a second terminal while the example application runs. Review the YGC, YGCT, FGC, FGCT, and GCT columns to assess young, full, and total GC activity.The program prints a startup message and then rapidly allocates many String objects to fill the heap. This makes GC behavior easier to observe so you can compare runs under different configurations.
For JDK 11 and later, run
java -Xms512m -Xmx1024m -XX:+UseSerialGC -Xlog:gc:file=gc.log:tags,uptime,time,level:filecount=10,filesize=16m HeapUsageExample.java. For JDK 8, use the -Xloggc:gc.log, -XX:+PrintGCTimeStamps, and -XX:+UseGCLogFileRotation options instead. Both commands create a gc.log file.