问题
Possible Duplicate:
Can I force generation of a JVM crash log file?
How can I force or generate a JVM core dump on an Java application server or in general?
回答1:
Problem(Abstract): To diagnose the problems related to hang or poor performance of customer applications running on WebSphere Application Server Community Edition, users would be required to generate the various dumps and send them to IBM Support for diagnosis.
This technote explains how to generate required dumps when WebSphere Application Server Community Edition is running as an operating system service. This technote applies to IBM Java SDK 1.5.0 and IBM Java SDK 1.6.0
Cause: When customer applications experience hang or poor performance with WebSphere Application Server Community Edition on IBM Java SDK 1.5.0 or IBM Java SDK 1.6.0, and the server is running as an operating system service, the corresponding command/shell window of the server process is not available to users. As a result, user signals can not be sent from the keyboard to trigger dumps.
Resolving the problem: When the JVM process command window is available, generating dumps is straight forward as follows:
Windows:
If the JVM setting is configured to trigger the dumps at user signal, press CRTL+Break
on the command window to generate the dumps.
Linux: If the JVM setting is configured to generate the dumps at user signal, press CTRL+\
on the shell window.
AIX: If the JVM setting is configured to generate the dumps at user signal, press CTRL+\
on the shell window.
Note: In order to generate java core dump, system core dump, heap dump and a snap dump at user signal, the dump agents must be configured through JVM options as follows:
-Xdump:java+heap+system+snap:events=user
For more information on how to configure dump agents, visit using -Xdump
.
However, if WebSphere Application Server Community Edition is running as an operating system service, the command window may not be available. This case will also arise when JVM process is started with javaw.exe on windows.
In the preceding circumstances, user is required to find the corresponding process-id of the JVM process and use operating system vendor supplied or IBM supplied tools to generate the dumps by following the below steps.
Windows: WinDbg can be downloaded from Microsoft Dev tools site to generate system core dumps. Use the following command at the WinDbg console to generate the system core dump:
dump /f <dumpfile>
Where dumpfile includes the directory path and the name of the system core dump file.
Make sure that /f
option is used instead of /ma
. The /f
generates full dump where as /ma
generates mini dump. Only full dumps are supported with the jextract tool supplied with IBM Java SDK 1.5.0/1.6.0.
SendSignal utility for Windows. For this, the JVM must be setup to generate the dumps on user signals. To generate the java core dump, heap dump, system core dump and a snap dump at user signal, the following option must be supplied to JVM at startup:
-Xdump:java+heap+system+snap:events=user
Note: The SendSignal utility can be used to generate all types of dumps where as WinDbg generate only system core dumps.
Linux and AIX
: The signal for Linux and AIX is SIGQUIT
. Use the command to send the user signal to trigger the various dumps:
kill -3 <PID>
For this, JVM must be setup to generate the dumps on user signal. To generate the java core dump, heap dump, system core dump and a snap sump at user signal, the following option must be supplied to JVM at startup.
-Xdump:java+heap+system+snap:events=user
Note: System core dump files must processed using the jextract tool and the output must be send to IBM support. The jextract from the same JVM that experienced the problem should be used to process the system core dump:
<JAVA_HOME>/jre/bin/jextract <dumpfile>
Where dumpfile is the filename of the system core dump.
This will produce a zip file .zip. The zip file needs to be sent to IBM support.
回答2:
If you're running your own code the Q&D way is to raise an exception and immediately print its stacktrace. If not, profiling tools should have ways to capture snapshots of the threads running in your JVM. I've used YourKit and liked it, but there are free alternatives.
来源:https://stackoverflow.com/questions/5576672/force-or-generate-jvm-core-dump-ibm-jvm