NewRatio: to twiddle or not to twiddle

Paul Hohensee Paul.Hohensee at Sun.COM
Tue Sep 2 12:25:55 PDT 2008

You probably want hotspot-gc-use at

A NewRatio of 1 means that half the heap is young gen.  The default
for the server vm is 2 (1/3 the heap is young gen) and for the client
vm it's 12 on x86 and 8 on sparc.  I.e., much smaller young gen for

1. A NewRatio of 1 doesn't allow transient objects to get collected more
quickly, it allows them time to die in the young gen and thus not get
collected at all.  The bigger the young gen, the longer the interval
between collections, and the more time for transient objects to die.

2. Is correct.

You can increase the amount of time transient objects have to die by
increasing MaxTenuringThreshold.  It can have values between 0 and 15,
and is the number of times an object must survive a young gen collection
before being promoted to the old gen.  The survivor spaces in the young gen
must be large enough to contain everything that's live in the young gen, 
the excess gets promoted before its time.  So check out lower values of
SurvivorRatio as well: lower values increase the size of the survivor 


Charles Oliver Nutter wrote:
> I've ben playing with JRuby on various benchmarks recently and found 
> that several object-intensive scripts run better if I set NewRatio=1. 
> Ruby, even more than Java, tends to generate lots and lots of objects, 
> especially considering that there's no unboxed primitive numeric types 
> (and no fixnums on the JVM...ahem ahem). So my general theory is that:
> 1. A NewRatio of 1 allows all those extra transient objects to get 
> collected more quickly.
> 2. Too small a "new" generation causes transient objects to get shoved 
> into older generations, potentially snowballing and forcing more 
> comprehensive GC runs as time goes on.
> I'm curious whether this theory sounds reasonable, whether there's a 
> better way I can adapt hotspot to the memory demands of a dynamic 
> language like Ruby, and what other implications there are in setting 
> NewRatio to 1.
> Thoughts?
> (And please let me know if there's a better list to post this sort of 
> question to)
> - Charlie

More information about the hotspot-dev mailing list