-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8u192
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
A DESCRIPTION OF THE PROBLEM :
Javadoc of method ArrayList.ensureCapacity does not restrict the capacity of the ArrayList.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the sample program
2. Run it using Oracle HotSpot java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The ArrayList capacity increased by Integer.MAX_VALUE.
ACTUAL -
Exception in thread "main" java.lang.OutOfMemoryError: Requested array size exceeds VM limit
at java.util.Arrays.copyOf(Arrays.java:3210)
at java.util.Arrays.copyOf(Arrays.java:3181)
at java.util.ArrayList.grow(ArrayList.java:265)
at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:239)
at java.util.ArrayList.ensureCapacity(ArrayList.java:219)
at A.main(A.java:6)
---------- BEGIN SOURCE ----------
public class A {
public static void main(String args[]) {
ArrayList al = new ArrayList();
al.ensureCapacity(Integer.MAX_VALUE);
}
}
---------- END SOURCE ----------
FREQUENCY : always
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
A DESCRIPTION OF THE PROBLEM :
Javadoc of method ArrayList.ensureCapacity does not restrict the capacity of the ArrayList.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the sample program
2. Run it using Oracle HotSpot java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The ArrayList capacity increased by Integer.MAX_VALUE.
ACTUAL -
Exception in thread "main" java.lang.OutOfMemoryError: Requested array size exceeds VM limit
at java.util.Arrays.copyOf(Arrays.java:3210)
at java.util.Arrays.copyOf(Arrays.java:3181)
at java.util.ArrayList.grow(ArrayList.java:265)
at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:239)
at java.util.ArrayList.ensureCapacity(ArrayList.java:219)
at A.main(A.java:6)
---------- BEGIN SOURCE ----------
public class A {
public static void main(String args[]) {
ArrayList al = new ArrayList();
al.ensureCapacity(Integer.MAX_VALUE);
}
}
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8029587 Jdk 7u45 > java.lang.outofmemoryerror: requested array size exceeds vm limit
-
- Closed
-
- relates to
-
JDK-8258565 ArrayList.ensureCapacity specification missing maximum capacity
-
- Open
-