FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
FULL OS VERSION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
x64, Intel Xeon CPU e5-1620 v3 3,5 GHz
A DESCRIPTION OF THE PROBLEM :
While running the code listed in the field "Source code for an executable test case" with the GC1 garbage collector (enabled by commandline options "-Xmx192m -XX:+UseG1GC") an OutOfMemoryError is thrown at a random time.
The loop in the test case is doing the same operations every time. if one run works without OOME, all runs should run without OOME.
If the flag "-XX:+UseG1GC" is removed, the code runs without OOME.
THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try
THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Did not try
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. run Source code for an executable test case" with the VM options "-Xmx192m -XX:+UseG1GC"
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected: normal execution of the sampe code
Actual: OutOfMemoryError is thrown
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
String name = "round #" + i;
System.out.println(name);
Collection<String> tmp = IntStream
.range(0, 10000000)
.parallel().mapToObj((c) -> name)
.collect(Collectors.toList());
}
System.out.println("PASSED");
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Not to use GC1, just remove -XX:+UseG1GC from the VM options.