Friday, June 29, 2012

How to get a HPROF heap dump in JAVA Stack?

How to get a HPROF heap dump in JAVA Stack?
Are you running an AS Java Weekstone with SAP JVM...
 •Use the ConfigTool to configure the following VM parameters:
 -XX:+HeapDumpOnOutOfMemoryError
 -XX:+HeapDumpOnCtrlBreak
•In SAP MMC right-click on the AS Java server process and select Dump Stack Trace
•The heap file is written to the working directory of the server, e.g. /usr/sap//J/j2ee/cluster/server/

...or a plain Java Application?
 •If you are running a SAP JVM, use ~/bin/jvmmon.exe
•On a Sun or HP VM please see the table below.

All options to get an HPROF dump in detail...

via Java VM parameters (see ConfigTool on how to set those for AS Java installations):
 •-XX:+HeapDumpOnOutOfMemoryError writes heap dump on OutOfMemoryError (recommended)
•-XX:+HeapDumpOnCtrlBreak writes heap dump together with thread dump on CTRL+BREAK (recommended; use SAP MMC to trigger dumps for AS Java installations)
•-agentlib:hprof=heap=dump,format=b combines the above two settings (old way; not recommended as the VM frequently dies after CTRL+BREAK with strange errors)