Monitoring/Tuning Garbage Collections Flags
-verbose:gc- Prints the Garbage Collector activities such as whether they performed Minor GC, Full GC, etc.
-XX:-UseAdaptiveSizePolicy- Young Generation space like Eden, S0 and S1 area is dynamically being resized by the virtual machine in runtime. This flag is to disable that feature.
-XX:NewRatio=n- The ratio of the size between Young Generation and Old Generation
- ex) NewRatio=4 means Old Generation is 4 times bigger than the Young Generation
-XX:SurvivorRatio=n- The ratio of each S0 and S1 of total Young Generation size. The rest of them will be Eden space.
- ex) SurvivorRatio=8 means each S0 and S1 space is 1/8 of the Young Generation. And the rest of them(6/8) will be Eden space.
- Note that even though we set this value, the virtual machine can update the size in runtime for optimization.
-XX:MaxTenuringThreshold=n- How many generations to an object survive before it becomes an Old Generation object. Which means to be the threshold to become an Old Generation object.
- 15 is maximum value for this flag, but some Java versions allow above.
However, it is always a bad idea to set it higher, because this means you’re not going to be using most of the Heap space(Old Generation).
Choosing a Garbage Collector
- Types of Collector
- Serial:
-XX:+UseSerialGC - Parallel:
-XX:+UseParallelGC - Mostly Concurrent:
-XX:+UseConcMarkSweepGC,-XX:+UseG1GCG1GCis mostly being set as a default garbage collector after Java 10.
- Serial:

Leave a comment