Is it possible to customize the java core and heap dump paths for Tomcat?
I've been trying to diagnose a memory issue with a CLM on Tomcat install using a small VMWare image but the heap and core dumps keep filling the root file system.
While I'm unable to re-size that volume, I could add a second volume and use that for the heap dumps but I don't see how to redirect the output.
Is there some command line arguments I could add that would allow us to use a custom path?
Accepted answer
You can use -Xdump which is documented a fair amount in this article. I added the settings below to my Tomcat server.startup script and now all Java dumps are being written in /dumps with their associated timestamp/PID appended to the file name.
JAVA_OPTS="$JAVA_OPTS -Xdump:heap:label=/dumps/heapdump.%Y%m%d.%H%M%S.%pid.%seq.phd"
JAVA_OPTS="$JAVA_OPTS -Xdump:java:label=/dumps/javacore.%Y%m%d.%H%M%S.%pid.%seq.txt"
JAVA_OPTS="$JAVA_OPTS -Xdump:system:label=/dumps/core.%Y%m%d.%H%M%S.%pid.%seq.dmp"
JAVA_OPTS="$JAVA_OPTS -Xdump:snap:label=/dumps/Snap.%Y%m%d.%H%M%S.%pid.%seq.trc"
(Optional) JAVA_OPTS="$JAVA_OPTS -Xdump:what"
You can also add the -Xdump:what option above to the Java options to print details in the standard output log when the server starts up. You'll see this in the log:
Registered dump agents
----------------------
-Xdump:system:
events=gpf+user+abort+traceassert,
label=/dumps/core.%Y%m%d.%H%M%S.%pid.%seq.dmp,
range=1..0,
priority=999,
request=serial
----------------------
-Xdump:heap:
events=gpf+user,
label=/dumps/heapdump.%Y%m%d.%H%M%S.%pid.%seq.phd,
range=1..0,
priority=500,
request=exclusive+compact+prepwalk,
opts=PHD
----------------------
-Xdump:heap:
events=systhrow,
filter=java/lang/OutOfMemoryError,
label=/dumps/heapdump.%Y%m%d.%H%M%S.%pid.%seq.phd,
range=1..4,
priority=500,
request=exclusive+compact+prepwalk,
opts=PHD
----------------------
-Xdump:java:
events=gpf+user+abort+traceassert,
label=/dumps/javacore.%Y%m%d.%H%M%S.%pid.%seq.txt,
range=1..0,
priority=400,
request=exclusive+preempt
----------------------
-Xdump:java:
events=systhrow,
filter=java/lang/OutOfMemoryError,
label=/dumps/javacore.%Y%m%d.%H%M%S.%pid.%seq.txt,
range=1..4,
priority=400,
request=exclusive+preempt
----------------------
-Xdump:snap:
events=gpf+user+abort+traceassert,
label=/dumps/Snap.%Y%m%d.%H%M%S.%pid.%seq.trc,
range=1..0,
priority=300,
request=serial
----------------------
-Xdump:snap:
events=systhrow,
filter=java/lang/OutOfMemoryError,
label=/dumps/Snap.%Y%m%d.%H%M%S.%pid.%seq.trc,
range=1..4,
priority=300,
request=serial
----------------------
JAVA_OPTS="$JAVA_OPTS -Xdump:heap:label=/dumps/heapdump.%Y%m%d.%H%M%S.%pid.%seq.phd"
JAVA_OPTS="$JAVA_OPTS -Xdump:java:label=/dumps/javacore.%Y%m%d.%H%M%S.%pid.%seq.txt"
JAVA_OPTS="$JAVA_OPTS -Xdump:system:label=/dumps/core.%Y%m%d.%H%M%S.%pid.%seq.dmp"
JAVA_OPTS="$JAVA_OPTS -Xdump:snap:label=/dumps/Snap.%Y%m%d.%H%M%S.%pid.%seq.trc"
(Optional) JAVA_OPTS="$JAVA_OPTS -Xdump:what"
You can also add the -Xdump:what option above to the Java options to print details in the standard output log when the server starts up. You'll see this in the log:
Registered dump agents
----------------------
-Xdump:system:
events=gpf+user+abort+traceassert,
label=/dumps/core.%Y%m%d.%H%M%S.%pid.%seq.dmp,
range=1..0,
priority=999,
request=serial
----------------------
-Xdump:heap:
events=gpf+user,
label=/dumps/heapdump.%Y%m%d.%H%M%S.%pid.%seq.phd,
range=1..0,
priority=500,
request=exclusive+compact+prepwalk,
opts=PHD
----------------------
-Xdump:heap:
events=systhrow,
filter=java/lang/OutOfMemoryError,
label=/dumps/heapdump.%Y%m%d.%H%M%S.%pid.%seq.phd,
range=1..4,
priority=500,
request=exclusive+compact+prepwalk,
opts=PHD
----------------------
-Xdump:java:
events=gpf+user+abort+traceassert,
label=/dumps/javacore.%Y%m%d.%H%M%S.%pid.%seq.txt,
range=1..0,
priority=400,
request=exclusive+preempt
----------------------
-Xdump:java:
events=systhrow,
filter=java/lang/OutOfMemoryError,
label=/dumps/javacore.%Y%m%d.%H%M%S.%pid.%seq.txt,
range=1..4,
priority=400,
request=exclusive+preempt
----------------------
-Xdump:snap:
events=gpf+user+abort+traceassert,
label=/dumps/Snap.%Y%m%d.%H%M%S.%pid.%seq.trc,
range=1..0,
priority=300,
request=serial
----------------------
-Xdump:snap:
events=systhrow,
filter=java/lang/OutOfMemoryError,
label=/dumps/Snap.%Y%m%d.%H%M%S.%pid.%seq.trc,
range=1..4,
priority=300,
request=serial
----------------------
One other answer
Alex,
These options maybe available in the IBM JAVA version. Here is a link to the Oracle version, Java Debug Options. You would have to modify the startup script to include these options.
*** UPDATE ***
Here is a link that talks about IBM specific options. Looks like environment variables have to be set not JRE options.
*** UPDATE 2 ***
Here is some IBM support information: IBM Support Doc
To specify the Heap Dump path, add -XX:HeapDumpPath=<path> to the parameters (i.e. - -XX:HeapDumpPath=./java_pid.hprof)