NewRatio: to twiddle or not to twiddle

Peter B. Kessler Peter.Kessler at Sun.COM
Tue Sep 2 13:09:29 PDT 2008

Why limit yourself to NewRatio?  The best you can get that way is half 
the heap for the young generation.  If you really want to a big young 
generation (to give your temporary objects time to die without even 
being looked at by the collector), use -Xmn (or -XX:NewSize= and 
-XX:MaxNewSize=) to set it directly.  Figure out what your live data 
size is and use that as the base size for the old generation.  Then 
figure out what kinds of pauses the young generation collections impose, 
and how much they promote, then amortize the eventual old generation 
collection time over as many young generation collections as you can 
give space to in the old generation.  Then make your total heap (-Xmx) 
as big as you can afford to get as big a young generation as that will 

			... peter

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