Force a heap-dump

This article explains ways to force the machine, your HiveMQ broker is running on, to create a heap-dump of the current HiveMQ process. Creating heap-dumps puts a certain amount of strain on your system and therefore we will be looking at typical pitfalls and best practises.

Do not create a heap-dump on your production system unless a member of the HiveMQ Support team clarified the action with you!

Instructions

Make sure you are running these command with a user that has sufficient permissions i.e. root or the HiveMQ run user

HiveMQ 3.x (JDK 8+)

  1. Find the processID <pid> for the HiveMQ process by running: ps aux | grep hivemq

  2. Run jmap -dump:file=heap.bin <pid>
    Alternative: jcmd <pid> GC.heap_dump filename=heap.bin

  3. Compress the heap.bin file and upload it to your HiveMQ Support Ticket

HiveMQ 4.x (JDK 11+) 

  1. Find the processID <pid> for the HiveMQ process by running: ps aux | grep hivemq

  2. Run jhsdb jmap --binaryheap --dumpfile heap.bin --pid <pid>
    Alternative: jcmd <pid> GC.heap_dump /opt/hivemq/heap.bin

  3. Compress the heap.bin file and upload it to your HiveMQ Support Ticket

Inside a Docker Container

curl -L https://github.com/apangin/jattach/releases/download/v2.0/jattach > jattach && \ chmod +x jattach && ./jattach 1 dumpheap heap-dump.hprof