-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
11.0.19
-
x86_64
-
linux_ubuntu
ADDITIONAL SYSTEM INFORMATION :
>jdk1.8.0_371_hotspot/bin/java -version
java version "1.8.0_371"
Java(TM) SE Runtime Environment (build 1.8.0_371-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.371-b11, mixed mode)
> jdk-11.0.19_hotspot/bin/java -version
java version "11.0.19" 2023-04-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.19+9-LTS-224)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.19+9-LTS-224, mixed mode)
> jdk-17.0.7_hotspot/bin/java -version
java version "17.0.7" 2023-04-18 LTS
Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
During my testing of the G1 collector in JDK8, JDK11, and JDK17, I noticed that only JDK11 threw an OutOfMemoryError (OOME) when running the same program. In theory, different versions of the G1 collector in different JDKs should exhibit the same behavior, either throwing or not throwing an OOME. While testing the program, I set the maximum heap memory to 1GB, which is relatively small, but the program should only occupy around 784MB of heap memory at its highest point. Considering memory fragmentation and the JVM's own usage, the actual memory usage may be slightly higher. Theoretically, JDK11 should perform equally or even better than JDK8, but in practice, JDK11 throws an OOME while JDK8 does not.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
> jdk1.8.0_371_hotspot/bin/java -Xms1024m -Xmx1024m -XX:+UseG1GC Case
<no output>
> jdk-11.0.19_hotspot/bin/java -Xms1024m -Xmx1024m -XX:+UseG1GC Case
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at Case.main(Case.java:27)
> jdk-17.0.7_hotspot/bin/java -Xms1024m -Xmx1024m -XX:+UseG1GC Case
<no output>
ACTUAL -
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at Case.main(Case.java:27)
---------- BEGIN SOURCE ----------
public class Case {
public static void main(String[] var0) {
byte[] arr1 = new byte[32 * 1024];
byte[] arr2 = new byte[32 * 1024 * 1024];
byte[] arr4 = new byte[512 * 1024 * 1024];
arr1 = new byte[32 * 1024];
arr4 = null;
byte[] arr3 = new byte[512 * 1024 * 1024];
arr2 = null;
byte[] arr5 = new byte[16 * 1024 * 1024];
arr3 = null;
arr3 = new byte[128 * 1024 * 1024];
byte[] arr6 = new byte[256 * 1024];
arr1 = new byte[64 * 1024];
arr2 = null;
arr3 = null;
arr6 = null;
arr6 = new byte[256 * 1024];
arr6 = null;
arr4 = null;
arr2 = new byte[256 * 1024 * 1024];
arr1 = null;
arr3 = null;
arr3 = new byte[64 * 1024];
arr6 = new byte[512 * 1024];
arr4 = new byte[512 * 1024 * 1024];
}
}
---------- END SOURCE ----------
FREQUENCY : always
>jdk1.8.0_371_hotspot/bin/java -version
java version "1.8.0_371"
Java(TM) SE Runtime Environment (build 1.8.0_371-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.371-b11, mixed mode)
> jdk-11.0.19_hotspot/bin/java -version
java version "11.0.19" 2023-04-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.19+9-LTS-224)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.19+9-LTS-224, mixed mode)
> jdk-17.0.7_hotspot/bin/java -version
java version "17.0.7" 2023-04-18 LTS
Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
During my testing of the G1 collector in JDK8, JDK11, and JDK17, I noticed that only JDK11 threw an OutOfMemoryError (OOME) when running the same program. In theory, different versions of the G1 collector in different JDKs should exhibit the same behavior, either throwing or not throwing an OOME. While testing the program, I set the maximum heap memory to 1GB, which is relatively small, but the program should only occupy around 784MB of heap memory at its highest point. Considering memory fragmentation and the JVM's own usage, the actual memory usage may be slightly higher. Theoretically, JDK11 should perform equally or even better than JDK8, but in practice, JDK11 throws an OOME while JDK8 does not.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
> jdk1.8.0_371_hotspot/bin/java -Xms1024m -Xmx1024m -XX:+UseG1GC Case
<no output>
> jdk-11.0.19_hotspot/bin/java -Xms1024m -Xmx1024m -XX:+UseG1GC Case
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at Case.main(Case.java:27)
> jdk-17.0.7_hotspot/bin/java -Xms1024m -Xmx1024m -XX:+UseG1GC Case
<no output>
ACTUAL -
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at Case.main(Case.java:27)
---------- BEGIN SOURCE ----------
public class Case {
public static void main(String[] var0) {
byte[] arr1 = new byte[32 * 1024];
byte[] arr2 = new byte[32 * 1024 * 1024];
byte[] arr4 = new byte[512 * 1024 * 1024];
arr1 = new byte[32 * 1024];
arr4 = null;
byte[] arr3 = new byte[512 * 1024 * 1024];
arr2 = null;
byte[] arr5 = new byte[16 * 1024 * 1024];
arr3 = null;
arr3 = new byte[128 * 1024 * 1024];
byte[] arr6 = new byte[256 * 1024];
arr1 = new byte[64 * 1024];
arr2 = null;
arr3 = null;
arr6 = null;
arr6 = new byte[256 * 1024];
arr6 = null;
arr4 = null;
arr2 = new byte[256 * 1024 * 1024];
arr1 = null;
arr3 = null;
arr3 = new byte[64 * 1024];
arr6 = new byte[512 * 1024];
arr4 = new byte[512 * 1024 * 1024];
}
}
---------- END SOURCE ----------
FREQUENCY : always