Using -XX:HeapDumpPath option but want to integrate the process id

32,548

Solution 1

That can be a path to a file OR directory. If you have a path to a directory, the generated file name will have pid in it by default.

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

Solution 2

You should add which Java you use. These options depends on the JVM vendor (IBM, Oracle, etc.)

OnOutOfMemoryError says WHEN to perform the dump. HeapDumpPath says WHERE to put the dump. I think the use of HeapDumpPath turns on the first, but I advice to use both for clarity.

About the original question, use the pid in the dump file name is a good practice. It can help in particular to corolate and analyse what happens after multiple issues/restarts.

The exact syntax is explained here.

Share:
32,548
Admin
Author by

Admin

Updated on May 18, 2021

Comments

  • Admin
    Admin almost 3 years

    When using -XX:+HeapDumpOnOutOfMemoryError the JVM will not overwrite the heap dump if there is already a dump file under the specified path. I want to be able to have multiple heap dumps in a non-default location, and was planning on using the pid in the heap dump path in order to allow that.

    However, when I tried to specify the argument like so:

    -XX:HeapDumpPath=some/heapdump/path/heapdump-%p.hprof
    

    And then created a heap dump, I got %p and not the actual pid in the file name. However, the use of %p seems to work with the -XX:OnOutOfMemoryError option. Is there some other syntax that I'm supposed to use for -XX:HeapDumpPath=?

  • Prathamesh dhanawade
    Prathamesh dhanawade about 5 years
    I am trying to do "some stuff" ONLY if there is a directory /path/to/heapdump present/exists. What happens when the path provided in /path/to/heapdump does not exist but is set in HeapDumpPath? On OOME, does jvm create the path and then create the heapdump at that path?