Heap Dump on OutOfMemoryError - alexpron/shanoir-ng GitHub Wiki

This page might help you get and analyze the java heap dump in case of a OutOfMemoryError.

1. First add parameters to the java run command in docker-compose/Dockerfile :

the java run command look like this :

ENTRYPOINT ["/bin/entrypoint", "java",...

so add those

-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/tmp/heapdumps

On crash a heap dump file that could weight several Gb will be written in /tmp/heapdumps, into the docker container

2. Get the heap dump file on your local machine

On the qualif env, the /tmp is mounted via a docker volume to this directory on the docker host that you access with ssh :

/nas/shanoir-tmp/<instance-name>

Then you can scp it from your local machine with :

scp <ssh-user-name>@<ssh_ip>:/nas/shanoir-tmp/<instance-name-dir>/heapdumps ./

BUT ! you will need these rights :

  • unix read right
    • since the file is written by root your user on the server will not have the right to read or copy the file
    • here is a hack : if you use dk shell to log into the docker container you will be root and will be able to go to /tmp/heapdumps and chmod the file.
  • right to scp (that doesn't necessary comes with ssh right)
    • you will have to ask the server administrator

3. Analyze the file

You can use Eclipse Memory Analyzer, which can run as a standalone software without the need of Eclipse.

  • Rename your heapdump file with a .hprof extension
  • After install, click File > Open Heap Dump
  • It can take so times to parse
  • You may have a heap space error parsing the heap dump (how ironic)
    • if so increase the max memory :
      1. open the MemoryAnalyzer.ini file
      2. change the default -Xmx1024m to a larger size
    • the failed parsing will maybe block you, rename the heap dump file and start a new parsing
  • I like the view "dominator tree" to sort the java objects by size
⚠️ **GitHub.com Fallback** ⚠️