-XX:SurvivorRatio JVM parameters in java - Setting survivor spaces size



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>
  1. Young Generation
    • 1a) Eden,
    • 1b) S0 (Survivor space 0)
    • 1c) S1 (Survivor space 1)
  2. Old Generation (Tenured)
  3. Permanent Generation.


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.



Summary -

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.



RELATED LINKS>

 

Different type of garbage collectors in java>

>Serial collector / Serial GC (Garbage collector) in java

>Throughput GC (Garbage collector) or Parallel collector in java

>Concurrent Mark Sweep (CMS) collector / concurrent low pause garbage collector in java

>G1 garbage collector / Garbage first collector in java

>PS Scavenge and PS MarkSweep



Different between garbage collectors in java>

>Difference between Serial GC vs Throughput GC (Garbage collector) in java



JVM in detail - Garbage collection & heap structure >

>JVM Heap memory (Hotspot heap structure) with diagram in java


Young, Old (tenured) and Permanent Generation >

>What are Young, Old (tenured) and Permanent Generation in JVM in java


Minor, Major and Full garbage collection >

>What are Minor, Major and Full garbage collection in JVM in java



Important VM parameters >

>Most important and frequently used VM (JVM) PARAMETERS with examples in JVM Heap memory in java

>What are -Xms and -Xmx JVM parameters in java, And differences between them with examples

>-Xmn JVM parameters in java with examples - Setting young generation size

>What is -XX:NewRatio JVM parameters in java with examples - Setting young and old generation ratio

>What are -XX:NewSize and -XX:MaxNewSize JVM parameters in java

>-XX:SurvivorRatio JVM parameters in java with examples - Setting survivor spaces size

>-XX:+AggressiveHeap VM parameters

>What are -XX:PermSize and -XX:MaxPermSize JVM parameters with examples in java | Differences

>Solve java.lang.OutOfMemoryError : unable to create new native Thread - Xss JVM option

More VM parameters >

>How to use -verbose:gc VM argument

>-Xverify option in java


eEdit
Must read for you :