Previous Next JavaScript must be enabled to correctly display this content

## 5.1 Extract Heapdump

This topic describes about the troubleshooting information to extract Heapdump.

If there is an error like GC Overhead limit exceeded or OutOfMemoryException is thrown while starting the services, the following details need to be shared.

Heap Dump

A heap dump is a snapshot of objects that are in memory in the JVM at a certain timestamp in a transaction. Heap dumps help to troubleshoot memory-leak problems and optimize memory usage in microservices. Heap dumps are usually stored in binary format hprof files.

The HeapDumpOnOutOfMemoryError command-line option that generates a heap dump when a java.lang.OutOfMemoryError is thrown can be used to generate heap dumps:

`java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<file-or-dir-path>`

Remote Heap Monitor Setup

Alternatively, one can setup remote heap monitor to observe the memory leaks in the product. Perform the following steps:

1. To enable jmx, set the following environment variable to start jmx:
   - -Dcom.sun.management.jmxremote
   - -Dcom.sun.management.jmxremote.port=8888
   - -Dcom.sun.management.jmxremote.authenticate=false
   - -Dcom.sun.management.jmxremote.ssl=false

   Note:

   If the above variable are set, a jmx service will start on specified port.
2. Setup JVisualVM as follows, to collect heap dumps:
   - Start JVisualVM.
   - Under "Remote" option, add a host.
   - Under the new host, add new jmx connection.

   Note:

   With this setup, the JAVA process can be monitored remotely.

Parent topic: Troubleshooting OutOfMemory issues