I created a heap dump file with hprof using this command:
java -agentlib:hprof -cp "..\..\jars\trove.jar;.\bin" com.mysite.MyApp
This successfully created the file "java.hprof.txt" which was about 5MB. I then opened up jvisualvm to view this file, and loaded it in. But visualvm appears to be stuck on the loading screen. The screen below has been up for about 10 minutes now.
Did I miss a step? Should I have used different options on the command line with hprof? How can I read this heap dump file?
VisualVM supports heap dumps in binary HPROF format. It is easier to use VisualVM to create heap dump. If this is not possible use VisualVM, you can use jmap -dump:live,format=b,file=heap.bin <pid>
. The advantage is that you don't need any special startup arguments and there is no slow down caused by hprof agent library.
In my case, I have resolved this issue by changing file permission of heapdump file. It turned out VisualVM tried to load the file but permission is denied (which is strange since VisualVM is the one created the dump file), however VisualVM does NOT give you error message. I have downloaded the eclipse memory analyzer (https://www.eclipse.org/mat/downloads.php). It gives me an error message.