Intro
For generating heap dumps on JDK 11 is pretty straight forward, following the previous versions – just add the flag when calling java:
-XX:+HeapDumpOnOutOfMemoryError
Generating
[@your_computer] java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/JDK11/java_application
Generated file
The generated file will be java_pid[number].hprof
Tests
For testing, I used the scripts from here
Actually, the second example is pretty straight forward – Error 2 – GC Overhead limit exceeded
// Java program to illustrate
// GC Overhead limit exceeded
import
java.util.*;
public
class
Wrapper {
public
static
void
main(String args[])
throws
Exception
{
Map m =
new
HashMap();
m = System.getProperties();
Random r =
new
Random();
while
(
true
) {
m.put(r.nextInt(),
"randomValue"
);
}
}
}
But I didn’t run with his suggestion and instead, run it without it. Just to see how long it would take. I regretted because the file is huge!