Heap dumps in JDK 11

All

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!

REFs

  Scripts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s