How to read heap dump file which is created by jconsole? - java

I performed a heap dump manually by invoking the com.sun.management.HotSpotDiagnostic MXBean's dumpHeap operation in jconsole. So I got a dump file.
My question:
Can jconsole read the dump file? If not, which tool can read it? Thanks!
EDIT: Now I know jconsole doesn't provide read feature, I am wondering reason why jconsole only writes dump file without read feature. (This is not my question, I am just curoius about it)

I found an Eclipse plugin Memory Analyzer to read the dump file by myself. Other tools are still welcome.

You can use jvisualvm.exe which comes with JDK 1.5 and above. Its present in bin folder of JDK. This is a very good tool which can be used to profile even the running Java applications.
You can even use JProfiler to read heap dump files. But this software is licensed.

Related

analyse a HPROF memory dump file from command line programmatically

I was investigation with analyzing a HPROF file using Eclipse's Memory Analyser (MAT).
The dominator tree, reports and the OQL interface look really useful. But all this has to be done manually from the MAT software.
Is there a commandline interface so I can programmatically parse the HPROF and automatically generate custom reports.
This would be useful to integrate this a test infrastructure to do a automatic memory analysis.
Btw, the heapsize is will be between 10-60MB.
ParseHeapDump.sh does what you're looking for. As for the follow up question I'm not sure what format the index files are stored in.
See bitbucket.org/joebowbeer/andromat, which is adapted from bitbucket.org/ekabanov/mat, which is a stripped-down command line version of Eclipse Memory Analyzer.

Making a "memory dump" of java application?

I have Java application, which, unfortunately, begins to consume quite big amounts of memory after some time. To complicate things, it's not only Java application, it is also JavaFX 2 application.
I suspect that there is some memory leak, maybe even in underlying JavaFX calls and native libs.
The ideal solution would be to get a dump of all java objects at some moment (with their memory usage), and then analyze that dump. Is there some way to achieve this?
Use jmap -heap:format=b <process-id> to create a binary dump of the heap which can then be loaded into several tools - my favorite being the "Eclipse Memory Analyzer"
There are lots of ways to get a heap dump, starting with simple tools like jmap to more fancy stuff like JVisualVM or even commerical tools as JProfiler. Correctly interpreting those dumps can be tricky though, so you might want to post exactly what you are looking for. Are going hunting for a memory leak, or are you interested in getting a general feel for your application?
You can use jvisualvm. It has plugin to see live memory and get a dump out of it.
I just re-discovered this article (archive.org archive) when researching ways to grab "JVM state right at this moment" - after a heap I pulled with jmap was about half the size of what the MBeans reported. I'll add it for completeness:
su $JVM_OWNER -c "gcore -o /tmp/jvm.core $YOUR_JVM_PID"
su $JVM_OWNER -c "jmap -dump:format=b,file=jvm.hprof /usr/bin/java /tmp/jvm.core"
Requires gdb installed (for gcore) and a JDK installation (for jmap). Also note you'd might need to adjust /usr/bin/java to the path of the JVM used for the process.

Viewing live heap in Eclipse

Is it possible to see the heap of a program in eclipse itself while it is executing? Is there a plugin for that?
I don't know if there is an Eclipse plugin, but if what matters is getting the information and not necessarily through Eclipse then you can do that with JVisualVM, and there are several plugins that provide all the details that you want.
One of its features is that you can make a heap dump.
Documentation says:
Take and browse heap dumps. When you need to browse contents of application memory or uncover a memory leak in your application,
you'll find the built-in HeapWalker tool really handy. It can read
files written in hprof format and is also able to browse heap dumps
created by the JVM on an OutOfMemoryException.
Eclipse does have a plugin called Eclipse Memory Analyzer (MAT). You can check it out here. I heard it is quite handy for heap analysis and fixing memory leaks in your program.
http://www.eclipse.org/mat/

Convert IBM .phdfile to .hprof heap dump format

I am trying to analyse a dump file from a websphere production machine, at the moment I am not succesfull because the file is of the type .phd, and well things would be alot easier when the file could be converted to .hprof
It is not generally possible to convert a PHD to HProf format. Have you tried using Eclipse MAT?
For PHD dumps use JProbe (see http://www.quest.com/jprobe), where you can import IBM PHD Dump files and analyze them. JProbe is a really powerful and easy to use tool for java profiling.
You can also use JProbe plug-in for Eclipse if you like Eclipse environment.
Regards, Lukas.

How do I analyze a .mdmp file?

I have java application that is crashing while in production. It doesn't do so in dev/QA. The jvm is creating a .mdmp file and a text file. How do I analyze the binary dump file? I googled but had no luck. We are using bea jrockit jvm 1.5 R27.
The .mdmp file is a Windows MiniDump file that you can only read with a debugger (like WinDbg). Typically you need the sources of the crashed application to really get some information out of the dump. So in your case you can't do much but contacting JRockit support.
Here a link to the Orace JRockit information about JVM crahes.
.mdmp files are the Windows equivalent of unix/linux core dumps. You can analyse them with WinDBG but if it's a Java process that has crashed most likely you'll want to use Java's own tools to analyse the crashed process.
If you want to look at the heap of the crashed Java process you can use a tool that ships with the JDK called jmap to extract a HPROF file from a .core or .mdmp and then load this into a memory analyser. Note also that some memory analyzers can load core dumps and Windows minidumps directly.
Related issue and the jmap docs
If you want to see the state of the threads then you can use a tool called jstack to print stack traces for every thread at the point the dump was created. jstack docs.

Categories

Resources