Generating Heap Dump
Java virtual machine heap dumps are used to diagnose memory and performance problems.
Automatic Heap Dumps
To set your server to generate heap dumps automatically when a heap out of memory error occurs:
- Open the startup script of your server with a text editor.
- Modify
JAVA_OPTS
to include the following:-XX:+HeapDumpOnOutOfMemoryError
. - Restart your server.
On Demand Heap Dumps
Elastic Path recommends using JMap
for generating heap dumps on demand.
note
JMap will essentially stop your JVM (Java Virtual Machine) throughput until it is complete; and it may take 10+ minutes.
Make sure your server is running.
With the command prompt, get the Java PID(Process Identifier) of your server using the following command:
jps -l
PID(Process Identifier) of the server will be identified by one of the Java class names listed below:- Tomcat 9.0:
org.apache.catalina.startup.Bootstrapstart
- Tomcat 9.0:
Run the following command to generate a
heap.bin
file in your current directory.jmap -heap:format=b <java_pid>
Analyzing the Heap Dump
Elastic Path recommends you use either the Eclipse Memory Analyzer Tool plugin or IBM HeapAnalyzer for analyzing heap.bin
.