Garbage Priority Garbage Collector (G1 GC) Use notes
G1 GC is a new garbage collection strategy, starting with JDK7, mainly for server-side JVM, and large memory applications, the goal is to achieve similar high-throughput CMS. G1 is still the idea of ??sub-management, the main use of the idea of ??block management, through the memory is divided into no more than 2048 blocks, each size between 1M-32M, Eden, Survivor space and old generation are one Series of discontinuous logical regions.
Here do not talk about the concrete realization of G1 ideas, only record how to configure and use.
Start the G1 GC
|
-XX: + UseG1GC
|
Several parameters and default values
-XX:MaxGCPauseMillis=200Maximum pause time, which is a target value, JVM will try to close to this target, the default value of 200.-XX:G1HeapRegionSize=nG1 area block size, 1M-32M, must be a power of 2, G1 will be based on the size of the block plan is not more than 2048 blocks.-XX:G1NewSizePercent=5Young generation in the heap in the smallest percentage, the default value is 5%-XX:G1MaxNewSizePercent=60The maximum percentage of young generations in the heap, the default is 60%-XX:ParallelGCThreads=nSets the value of the STW worker thread. Set the value of n to the number of logical processors. The value of n is the same as the number of logical processors, up to 8. If there are more than eight logical processors, set the value of n to about 5/8 of the number of logical processors. This applies to most cases unless it is a larger SPARC system, where the value of n can be about 5/16 of the number of logical processors.-XX:ConcGCThreads=nSets the number of threads that are marked in parallel. Set n to 1/4 of the amount of parallel garbage collection threads (ParallelGCThreads).-XX:InitiatingHeapOccupancyPercent=45Mark the garbage threshold, the default 45%-XX:G1ReservePercent=10Set the percentage of reserved memory as free space to reduce the risk of target space spillovers. The default value is 10%.
Suggest
- Avoid using the -Xmn option or other related options such as -XX: NewRatio to explicitly set the young generation size. Fixed young generation size will cover the pause time target.
- Pause time goals are not too small, because pause time and throughput are a contradictory indicator.
example
This is a simple configuration of tomcat startup
|
Export CATALINA_OPTS = “$ CATALINA_OPTS -Xms10g”
Export CATALINA_OPTS = “$ CATALINA_OPTS -Xmx10g”
Export CATALINA_OPTS = “$ CATALINA_OPTS -Xss512k”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: + DisableExplicitGC”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: + HeapDumpOnOutOfMemoryError”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: + UnlockExperimentalVMOptions”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: + UseG1GC”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: MaxGCPauseMillis = 200”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: G1NewSizePercent = 40”
Export CATALINA_OPTS = “$ CATALINA_OPTS -XX: G1MaxNewSizePercent = 80”
|
G1NewSizePercentAndG1MaxNewSizePercentexperimental properties, so please through the-XX:+UnlockExperimentalVMOptionsopen test option.
Done.

Recent Comments