How to set the ratio of the young generation to the old generation for garbage collection
 Technote (troubleshooting)
 
Problem(Abstract)
When the Java™ SDK is performing garbage collection (GC), use -XX:NewRatio to set the ratio of the young generation to the old generation.
 
Cause
If the young generation of the heap is too small, objects that could have been allocated then collected quickly, and allocated to the old generation where they remain until a full garbage collection is triggered. This wastes space in the heap.

If the young generation of the heap is too large, the garbage collection runs longer than necessary. This is because when the total size of the objects in the young generation is larger than the available space in the old generation, a full garbage collection is triggered instead.

The Java Virtual Machine cannot transfer all objects in the young generation to the old generation during the incremental (minor) garbage collection when there is not enough room in the old generation. This triggers a full garbage collection to free space in the old generation portion of the heap.

This scenario is officially known as violation of the young generation Guarantee. If the young generation is too large, full garbage collections occur too often and incremental garbage collections occur too infrequently.

 
Resolving the problem
Heap allocations are stored with two storage allocation retention strategies:
  • Young generations are removed from the heap during incremental (minor) garbage collection.
  • Old generations are removed from the heap only after a full garbage collection.

The optimum size for the young generation is generally somewhere between one quarter and one third of the total heap. For example, the following options can be set with -Xmx1024m:

-XX:NewRatio=2
-XX:MaxNewSize=256m

The NewRatio parameter controls the ratio of the young generation to the old generation:
  • A value of 2 means this ratio is 1:2. The young generation is resized continuously as the heap grows, so this is approximately one half the size of the old generation.
  • The default value for the ratio is 2 for operating in Server mode.
  • The MaxNewSize parameter sets the maximum size of the young generation.
 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > Java SDK
Operating system(s): Solaris
Software version: 5.1
Software edition:
Reference #: 1177289
IBM Group: Software Group
Modified date: Dec 14, 2006