Question
How do you collect a TBSM Server JVM Heap Dump?
Answer
Options for getting Java Heap Dump
1) Request Java to Dump Heap on an Out Of Memory error
Add the following to the JVM settings:
-XX:+HeapDumpOnOutOfMemoryError
-XX:+HeapDumpOnOutOfMemoryError
This option available in 1.5.0_07 and 1.4.2_12, producing an hprof binary format heap dump
hprof heap dumps are platform independent and so you don't need to analyze the dump on the same system that produced it
Running with -XX:+HeapDumpOnOutOfMemoryError does not impact performance - it is simply a flag to indicate that a heap dump should be generated when the first thread throws OutOfMemoryError.
Optional also:
-XX:HeapDumpPath=
-XX:HeapDumpPath
Specifies path to directory or filename for heap dump. (Introduced in 1.4.2 update 12, 5.0 update 7.)
Path to filename for heap dump, i.e. -XX:HeapDumpPath=/some/directory/filename.hprof
Note: On Windows, the JVM can stay trashing (running garbage collections) before it actually reports an OOM.
2) Force a Heap Dump, on demand (Unix Only)
On Unix, add the following to the JVM settings:
-XX:+HeapDumpOnCtrlBreak
This was available on Unix in beginning with SDK 1.4.2.11 and JDK 1.5.0.05.
Then do:
kill -QUIT <pid>
where is pid is the running java process for the application.
In 4.1.1, the command dumps the data into a text file in $NCHOME. You may do a : find . -name javacore* inside $NCHOME.
If using TBSM 4.2 or 4.2.1 the heap dump should be created in the hope directory of the profile i.e.
$TIP_HOME/profiles/TBSMProfile or $TIP_HOME/profiles/TIPProfile
Note: kill -QUIT is equivilant to kill -3 and kill -SIGQUIT
Note: For Windows -XX:+HeapDumpOnCtrlBreak was only introduces in 1.5.0_14. This is above the release of Java in TBSM 4.2.1 (1.5.0 SR 11) so this option is not possible in current TBSM versions on Windows.
3) Using eWAS (TBSM 4.2 and 4.2.1)
You can get a full JVM heap dump uses eWAS.
Note, that this is only works in Linux , Windows, and AIX.
$TIP_HOME/bin/wsadmin -username tipadmin -password <tipadmin password>
the script will take you to the was admin prompt:
For Impact:
<wsadmin>set objectName [$AdminControl queryNames WebSphere:type=JVM,process=server1,node=ImpactNode,*]
For Data Server
<wsadmin>set objectName [$AdminControl queryNames WebSphere:type=JVM,process=server1,node=TBSMNode,*]
For Dashboard Server
<wsadmin>set objectName [$AdminControl queryNames WebSphere:type=JVM,process=server1,node=TIPNode,*]
This command will set up the variable objectName, then in the prompt invoke it:
<wsadmin> $AdminControl invoke $objectName generateHeapDump
The command will dump the heap as .phd file in $TIP_HOME/profiles/TBSMProfile or $TIP_HOME/profiles/TIPProfile. It should give you the full path and name of the file.
NOTE: that in Linux if the application goes out of memory, it dump the above 2 steps by default. In Solaris, you have to specify it in a script.
4) JConsole
You could utilize JConsole by calling the HotSpotDiagnostic MBean and the dumpHeap operation if it's available from your Sun JVM.
Note: Jconsole is not shipped with the JRE in TBSM. You will need to install the 1.6 Java JDK for JConsole. 1.6 JDK can be installed on a client machine and can connect remotely to the TBSM JVM if the following startup JVM options are set for TBSM.
JConsole from 1.6 JDK can connect to earlier version of JVM, i.e. looks like you can use a 1.5 Sun JDK's JConsole to connect to a Sun 1.4.2 JVM:
http://forums.oracle.com/forums/thread.jspa?threadID=1175181&tstart=180 .
You can run JConsole on JDK 5.0 and still connect to an application running
on JDK 1.4.2. You will get access to your application MBeans through the MBeans tab but
you won't get access to the M&M tabs and platform MBeans as they didn't
exist in JDK 1.4.2.
If you need to access M&M tabs (threads, memory usage etc...),
your application have to run on JDK 5.0, started with
-Dcom.sun.management.jmxremote java option.
Set the following options:
-Dcom.sun.management.jmxremote.port=8086 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
See link for more information
To open jconsole (just type jconsole), and go to the mbeans tab. In the left hand tree structure look for the following folder; com.sun.management.
Expand and click on HotSpotDiagnostic. In the right hand window click on operations. There should be an option to dump the heap memory.
5) Jmap (only for version 1.6 on Windows)
jmap prints shared object memory maps or heap memory details of a given process or core file or a remote debug server.
This is not available on the JRE shipped with TBSM. For this (like JConsole) the JDK is required.
It is available on version 1.5 for Linux and 1.6 for Windows JDK.
Usage:
jmap -histo <pid>
(to print histogram of java object heap of the JVM process)
jmap -dump:<dump-options> <pid>
(to dump java heap of the JVM process)
dump-options:
format=b binary default
file=<file> dump heap to <file>
Example: jmap -dump:format=b,file=heap.bin <pid>
jmap -dump:live,file=heap.dump.out,format=b <pid>
Note: On windows you must have -Xrunhprof:heap=dump,format=b,file=C:\java.hprof,doe=y
NOTE: Xrunhprof caused TBSM to run slowly.