Currently, according to the comment in arrayOop.hpp, arrayOopDesc::max_array_length() we need to restrict array length for some element types:
// It should be ok to return max_jint here, but parts of the code
// (CollectedHeap, Klass::oop_oop_iterate(), and more) uses an int for
// passing around the size (in words) of an object. So, we need to avoid
// overflowing an int when we add the header. See CRs 4718400 and 7110613.
This should probably be fixed. The parts of code that use int for passing object size should use size_t or similar instead, in order to allow max_jint sized objects.
// It should be ok to return max_jint here, but parts of the code
// (CollectedHeap, Klass::oop_oop_iterate(), and more) uses an int for
// passing around the size (in words) of an object. So, we need to avoid
// overflowing an int when we add the header. See CRs 4718400 and 7110613.
This should probably be fixed. The parts of code that use int for passing object size should use size_t or similar instead, in order to allow max_jint sized objects.
- relates to
-
JDK-8029587 Jdk 7u45 > java.lang.outofmemoryerror: requested array size exceeds vm limit
- Closed
-
JDK-8059914 Cannot allocate array with Integer.MAX_VALUE elements
- Closed
-
JDK-8246725 Provide MAX_ARRAY_SIZE publicly
- Open