How to analyze information from a Java core dump? [closed]
Asked Answered
S

10

43

If a process crashes and leaves a core dump or I create one with gcore then how can I analyze it?

I'd like to be able to use jmap, jstack, jstat etc and also to see values of all variables.

This way I can find the reasons for a crashed or frozen JVM.

Sedation answered 4/6, 2009 at 14:53 Comment(2)
What is a Java core dump? Are you referring to the application's stack trace or did the JVM crash resulting in a core dump?Kirkkirkcaldy
Could we convert this into a wiki? This is not a programming question. It, however, very relevant for any java programmer on unix platform. Moving to softwarerecs.. is another choice. In any case please do not delete this..Hearse
A
45

Okay if you've created the core dump with gcore or gdb then you'll need to convert it to something called a HPROF file. These can be used by VisualVM, Netbeans or Eclipse's Memory Analyzer Tool (formerly SAP Memory Analyzer). I'd recommend Eclipse MAT.

To convert the file use the commandline tool jmap.

# jmap -dump:format=b,file=dump.hprof /usr/bin/java core.1234

where:

dump.hprof is the name of the hprof file you wish to create

/usr/bin/java is the path to the version of the java binary that generated the core dump

core.1234 is your regular core file.

Adown answered 28/7, 2009 at 8:38 Comment(4)
Can we convert a jdk 1.4 core dump file produced using gcore to hprof on solaris using jdk1.5/bin/jmap ? I tried using the above command but it gives the error : Error attaching to core file: can't find 'UseSharedSpaces' flagAttachment
techzen: I'm unsure on this I'm afraid.. are you definitely referencing the 1.4 java executable on the commandline? If so then it might just be that the 1.4 core dumps aren't compatible.Adown
Is it possible to use jmap to convert a mdmp file generated by JVM when it crashes (docs.oracle.com/cd/E15289_01/doc.40/e15059/crash.htm)?Sosthenna
Too bad I get this exception when running jmap command, somewhere at internet saying it is because it is difference version of java. However, as far as I know both java version should be same ( although it is on difference host ). And, let say it is difference, if there way to analysis core file for difference version of java? Exception in thread "main" java.lang.reflect.InvocationTargetException ..... Caused by: java.lang.InternalError: void* type hasn't been seen when parsing int *Agee
T
12

If you are using an IBM JVM, download the IBM Thread and Monitor Dump Analyzer. It is an excellent tool. It provides thread detail and can point out deadlocks, etc. The following blog post provides a nice overview on how to use it.

Tuatara answered 11/3, 2014 at 1:4 Comment(0)
L
5

Maybe VisualVM can help (haven't yet had a chance to try it myself). Link:

http://java.sun.com/javase/6/docs/technotes/guides/visualvm/coredumps.html

Lucilla answered 4/6, 2009 at 15:3 Comment(0)
T
5

Are you sure a core dump is what you want here? That will contain the raw guts of the running JVM, rather than java-level information. Perhaps a JVM heap dump is more what you need.

Triumphal answered 4/6, 2009 at 15:22 Comment(0)
O
2

Actually, VisualVM can process application core dump.

Just invoke "File/Add VM Coredump" and will add a new application in the application explorer. You can then take thread dump or heap dump of that JVM.

Obvert answered 22/10, 2009 at 7:3 Comment(2)
File add vm coredump is grayed out for me. Not sure why exactlySachsse
If you are on windows, it is not supported and will be greyed out unfortunately. I am in the same boat. visualvm.java.net/coredumps.html The Core Dump node is visible in the Applications window if VisualVM is running on Solaris or Linux.Annunciata
H
2

See http://www.oracle.com/technetwork/java/javase/tsg-vm-149989.pdf. You can use "jdb" directly on the core file.

Henricks answered 13/5, 2011 at 19:56 Comment(2)
That's a pretty big pdf you linked there. Mind giving a pointer to whatever you are referencing?Moskow
The section is entitled "Attaching to a Core File on the Same Machine" and the example command is jdb -connect sun.jvm.hotspot.jdi.SACoreAttachingConnector:\javaExecutable=$JAVA_HOME/bin/java,core=core.20441Jenevajeni
P
1

Try the lady4j stack analyzer, it could help you:

http://www.lady4j.com/solveStack.jsp

Photocompose answered 20/5, 2010 at 21:7 Comment(1)
It was closed some years ago, this answer should be hiddenDossal
P
0

IBM provide a number of tools which can be used on the sun jvm as well. Take a look at some of the projects on alphaworks, they provide a heap and thread dump analyzers

Karl

Pastern answered 4/6, 2009 at 15:2 Comment(0)
L
0

I recommend you to try Netbeans Profiler.It has rich set of tools for real time analysis. Tools from IbM are worth a try for offline analysis

Larrylars answered 4/6, 2009 at 15:12 Comment(0)
J
0

jhat is one of the best i have used so far.To take a core dump,I think you better use jmap and jps instead of gcore(i haven't used it).Check the link to see how to use jhat. http://www.lshift.net/blog/2006/03/08/java-memory-profiling-with-jmap-and-jhat

Jehol answered 27/7, 2010 at 7:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.