-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
17
In Java EPP and Java 17 a different exception for OOM is thrown when using parallel GC and G1GC, which could affect the behavior of related products when catching that particular exception. For example, WLS executes some internal tasks if an OOM is detected.
While UseParallelGC generates a Throwable, G1GC produces Exception: java.lang.OutOfMemoryError thrown from the
UncaughtExceptionHandler in thread "main"
Previously in JDK 8, this is the behavior of both UseG1GC and UseParallelGC -- the
exception is thrown to the calling thread, which can catch and process the
exception.
Test case:
public class Mem {
static java.util.ArrayList al = new java.util.ArrayList();
public static void main(String[] args) throws Exception {
try {
while(true) al.add(new byte[1024*1024]);
} catch (Throwable t) {
System.out.println("Caught exception; terminating");
}
}
}
While UseParallelGC generates a Throwable, G1GC produces Exception: java.lang.OutOfMemoryError thrown from the
UncaughtExceptionHandler in thread "main"
Previously in JDK 8, this is the behavior of both UseG1GC and UseParallelGC -- the
exception is thrown to the calling thread, which can catch and process the
exception.
Test case:
public class Mem {
static java.util.ArrayList al = new java.util.ArrayList();
public static void main(String[] args) throws Exception {
try {
while(true) al.add(new byte[1024*1024]);
} catch (Throwable t) {
System.out.println("Caught exception; terminating");
}
}
}