Controlling Java integer cache

Submitted by kofa on Thu, 04/28/2011 - 10:36

Useful for autoboxing.

By default, Integer.valueOf caches between -128 and 127 (min/max. of signed byte). However, you can increase this range by using:

-XX:+AggressiveOpts

and/or

-Djava.lang.Integer.IntegerCache.high

when launching the VM.

More details: http://www.javaspecialists.eu/archive/Issue191.html