jhat throwing unrecognized magic number
Asked Answered
C

3

6

I am trying to analyse a heap dump taken from a java process that ran into memory issues. The dump was taken using jmap. I am using jhat on the dump file - I am getting

java.io.IOException: Unrecognized magic number: 169897589 at com.sun.tools.hat.internal.parser.Reader.readFile(Reader.java:94) at com.sun.tools.hat.Main.main(Main.java:159)

Both jdk 1.6 and 1.7 give the same error. I am running the jhat on my Windows machine locally (after copying the dump file over ) and the dump file was taken on Linux server.

Any ideas what I am doing wrong ?

Collodion answered 19/3, 2013 at 18:0 Comment(2)
Can we see some code so we can have any idea of what you're doing wrong?Janeth
my question is about the jhat throwing the error - the source code should not be directly required for the question I believe.Collodion
G
5

If you take a look at the source code for com.sun.tools.hat.internal.parser.Reader, you'll see that it's looking for the magic number 0x4a415641.

This value is used to help identify valid heap dump files. jmap should append this value as the first four bytes of any heap dump file it creates.

I'd suggest opening up your heap dump in a hex editor and checking to see whether the first four bytes are 0x4a415641. Check this for the file on both your Linux and Windows machine. Perhaps the file is getting corrupted when you transfer the file.

Goldstone answered 19/3, 2013 at 18:44 Comment(0)
C
1

probably, U got the wrong way to generate jvm dump file. the error occurs when using jmap -histo {pid} > dump.log.

try

   jmap -dump:live;file=filename pid

Good luck.

Crypt answered 20/3, 2016 at 15:4 Comment(0)
T
0

Most probably, you are providing a zip file (.gz or .tar.gz) to the jhat tool. That's why it is not able to verify the hprof header. Recently, I ran across the same situation. My heap dump was captured on a Linux server in .tar.gz format and I supplied as is to get the same error which you got. After untarring the file, jhat was able to analyze the .hprof file.

Teddman answered 29/7, 2022 at 8:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.