1. JVM执行异常时,自动生成Javacore
1.1 发生了引起JVM停止运行的本地错误时,会自动产生Javacore文件
1.2 JVM内存不足时,会自动产生Javacore文件
2. 触发JVM生成JDK
2.1 从命令行中发出kill -3 <pid>指令,生成Javacore
2.2 在应用中调用com.ibm.jvm.Dump.JavaDump()方法,生成Javacore
2.3 使用WAS wsadmin utility命令生成Javacore, 以Jython语言为例:
jvm = AdminControl.completeObjectName('type=JVM,process=server1,*')
AdminControl.invoke(jvm, 'dumpThreads')
2.4 可以配置dump agent触发生成Javacore
dump agent提供了一些可配置的选项,详细见文档 http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/topic/com.ibm.java.doc.diagnostics.60/diag/tools/dump_agents.html
生成Javacore可以响应的事件列表如下:
2.5 可以使用trigger trace选项生成Javacore
例如:-Xtrace:trigger=method{java/lang/String.substring,javadump}
条件可以是:
method{<methodspec>[,<entryAction>[,<exitAction>[,<delayCount>
[,<matchcount>]]]]}
On entering a method that matches <methodspec>, the specified <entryAction> is run. On leaving a method that matches <methodspec>, the specified <exitAction> is run. If you specify a <delayCount>, the actions are performed only after a matching <methodspec> has been entered that many times. If you specify a <matchCount>, <entryAction> and <exitAction> are performed at most that many times.
group{<groupname>,<action>[,<delayCount>[,<matchcount>]]}
On finding any active tracepoint that is defined as being in trace group <groupname>, for example Entry or Exit, the specified action is run. If you specify a <delayCount>, the action is performed only after that many active tracepoints from group <groupname> have been found. If you specify a <matchCount>, <action> is performed at most that many times.
tpnid{<tpnid>|<tpnidRange>,<action>[,<delayCount>[,<matchcount>]]}
On finding the specified active <tpnid> (tracepoint ID) or a <tpnid> that falls inside the specified <tpnidRange>, the specified action is run. If you specify a <delayCount>, the action is performed only after the JVM finds such an active <tpnid> that many times. If you specify a <matchCount>, <action> is performed at most that many times.
参考文献
https://www.ibm.com/support/knowledgecenter/SSYKE2_6.0.0/com.ibm.java.doc.diagnostics.60/diag/tools/javadump_trigger.html
文章来源: IBM JDK生成Javacore的方法