Reputation: 191
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=
?
Upvotes: 19
Views: 44263
Reputation: 4215
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.
Upvotes: 2
Reputation: 6306
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
Upvotes: 20