开发者

Java, get core dump

开发者 https://www.devze.com 2023-02-01 15:04 出处:网络
I would like to be able to analyze a Java core dump in the same manner that one would analyze a core dump from a process on a UNIX system.However, I am not interested in having the information from th

I would like to be able to analyze a Java core dump in the same manner that one would analyze a core dump from a process on a UNIX system. However, I am not interested in having the information from the process, only the JVM level stack, heap, etc. The core dump would contain information on Java methods, variables, etc.

  1. How can I tell the JVM to build a Java-level core dump?
  2. What is a good tool to analyze said dump?

For instan开发者_StackOverflowce, if this code was executed

public static void foo() {
  //trigger core dump
}
public static void main(String args[]) {
 foo();
}

I would get a core dump showing a stack of main-->foo


The easy way to do this kind of thing is to attach an interactive debugger to the JVM, pause it, and use the debugger to look at the stacks, etc.


jstack <process id>

Will dump a stack trace of all of the running threads. You will need to be the same user as the running java process.


You can use jmap to generate a heap dump.

Once you have a heap dump, you can use a tool like the Eclipse Memory Analyzer Tool to examine the dump.

And if what you're looking for is a stack trace, try something like Thread.currentThread().getStackTrace().

0

精彩评论

暂无评论...
验证码 换一张
取 消