On Fri, Apr 16, 2010 at 03:17, David Holmes <[email protected]> wrote: > Hi Martin, > > Martin Buchholz said the following on 04/16/10 16:09: >> >> I recently discovered another place to handle huge arrays better - in >> AbstractCollection. >> I've put those changes into >> http://cr.openjdk.java.net/~martin/webrevs/openjdk7/ArrayResize2/ > > I don't understand what you are doing here: > > 194 * The maximum size of array to allocate. > 195 * Some VMs reserve some header words in an array. > 196 * Attempts to allocate larger arrays may result in > 197 * OutOfMemoryError: Requested array size exceeds VM limit > 198 */ > 199 private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; > > On 32-bit you can't get anywhere near this limit. On 64-bit Hotspot > currently allows you to allocate the entire array up to Integer.MAX_VALUE > elements for types <= 32-bit; and MAX_VALUE-3 for 64-bit. > > Regardless this is VM specific and I don't see what purpose this serves. > ???
I'm trying to avoid OOME due to exceeding the MAX_VALUE-3 limit on a 64-bit VM, when the number of actual elements is far smaller, say 75% of MAX_VALUE. Yes, you can think of this as a VM-specific bug workaround. Martin
