JDK-8029587 : Jdk 7u45 > java.lang.outofmemoryerror: requested array size exceeds vm limit
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Priority: P2
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2013-12-05
  • Updated: 2022-12-16
  • Resolved: 2013-12-09
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
 
SHORT SUMMARY:
 
Header size for arrays counted in bytes instead of words.
PRESENT SINCE:
  
7u4 

DESCRIPTION:
 
Header size is calculated incorrectly and that cause 
"java.lang.OutOfMemoryError: Requested array size exceeds VM limit".
 

Comments
The problem could be caused by next code in AbstractStringBuilder.expandCapacity() which set newCapacity to max_int: 125 if (newCapacity < 0) { 126 if (minimumCapacity < 0) // overflow 127 throw new OutOfMemoryError(); 128 newCapacity = Integer.MAX_VALUE; 129 } 130 value = Arrays.copyOf(value, newCapacity); Do we need to modify it?
28-01-2014

Closing this bug as will not fix since the current code works as designed. Background: In the GC code we pass around the size of objects in words as an int. When we add the header size of an object and then convert back from words to bytes we may overflow an int. This can cause crashes and unexpected behavior. By limiting the maximum array length to be (max size - header size) we avoid these issues. For more details see JDK-7110613 and JDK-4718400
09-12-2013