How to increase the cache size for an Integer object
1 answer
IntegerCache, for example. says the following:
/**
* Cache to support the object identity semantics of autoboxing for values between
* -128 and 127 (inclusive) as required by JLS.
*
* The cache is initialized on first usage. During VM initialization the
* getAndRemoveCacheProperties method may be used to get and remove any system
* properites that configure the cache size. At this time, the size of the
* cache may be controlled by the vm option -XX:AutoBoxCacheMax=<size>.
So either you are using the VM parameter or you are using the System property like:
-Djava.lang.Integer.IntegerCache.high=256
When starting the JVM.
+5
source to share