Creating Java Heap Dumps for JBoss EAP

15 minutes
  • 3 Learning Objectives

About this Hands-on Lab

While JBoss Enterprise Application Platform makes managing our Java applications more effective, there are still some troubleshooting tactics for Java applications that we should be aware of. Our applications can be memory-intensive, and in instances of poor performance, we’ll often need to take and analyze a Java heap dump to discover the root cause of our memory issues.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create Heap Dump
  1. Find the process ID for Java:

    pgrep java
  1. Create a heap dump:

    sudo jcmd PID GC.heap_dump -all=true heapcheck.hprof
  2. Check that the heap dump has been created in /opt/jboss-eap:

    cd /opt/jboss-eap
Configure Automatic Heap Dump Creation
  1. Create a directory to store heap dumps and move the heapcheck.hpof file to it:

    sudo mkdir /opt/jboss-eap/heapdumps
    sudo mv heapcheck.hprof /opt/jboss-eap/heapdumps/
  1. Configure JBoss to automatically generate a heap dump when there is an out of memory error; ensure it is saved to the newly-created directory:

    export JAVA_OPTS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/jboss-eap/heapdumps/oomdump.hprof"
  2. Restart JBoss:

    sudo systemctl restart jboss-eap-rhel
Parse the Heap Dump
  1. Download the Eclipse Memory Analyzer:

    curl -O
  2. Extract the contents of the download:

  3. Run the script to parse the heap dump:

    cd mat
    sudo ./ /opt/jboss-eap/
  4. Confirm the heap dump has been parsed:

    ls /opt/jboss-eap/heapdumps/

Additional Resources

An application has recently been showing inconsistent performance, and you wish to create a snapshot of the JVM heap in an attempt to troubleshoot the problem, then parse the file so analyzing it will be easier. Additionally, you wish to alter your JBoss EAP setup so heap dumps are created automatically when an out of memory error occurs. These heap dumps should be saved to /opt/jboss-eap/heapdumps.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!