In this core java tutorial we will learn What is -XX:SurvivorRatio JVM parameters in java.
Contents of page >
- What is -XX:SurvivorRatio JVM parameter in java?
- Examples of using -XX:SurvivorRatio VM option in java >
- What if survivor spaces are too small?
- What if survivor spaces are too large?
- Summary -
Before learning about -XX:SurvivorRatio JVM parameter in java we must know about java heap memory structure.
JVM Heap memory (Hotspot heap structure) in java consists of following elements>
- Young Generation
- 1a) Eden,
- 1b) S0 (Survivor space 0)
- 1c) S1 (Survivor space 1)
Old Generation (Tenured)
What is -XX:SurvivorRatio JVM parameter in java?
-XX:SurvivorRatio : (for survivor space)
SurvivorRatio can be used to tune the size of the survivor spaces, but this is often not as important for performance.
Example of using -XX:SurvivorRatio Vm option in java>
-XX:SurvivorRatio=6 sets the ratio between each survivor space and eden to be 1:6.
In other words, each survivor space will be one eighth of the young generation (not one seventh, because there are two survivor spaces).
What if survivor spaces are too small?
If survivor spaces are too small, copying collection overflows directly into the tenured generation.
What if survivor spaces are too large?
If survivor spaces are too large, they will be uselessly empty. At each garbage collection the virtual machine chooses a threshold number of times an object can be copied before it is tenured. This threshold is chosen to keep the survivors half full. -XX:+PrintTenuringDistribution can be used to show this threshold and the ages of objects in the new generation. It is also useful for observing the lifetime distribution of an application.
So in this core java tutorial we learned what is -XX:SurvivorRatio JVM parameters in java. And how to use -XX:SurvivorRatio VM parameter with examples.
Having any doubt? or you liked the tutorial! Please comment in below section.
Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.