forked from eaftan/hprof-parser
-
Notifications
You must be signed in to change notification settings - Fork 3
/
README
44 lines (35 loc) · 2.07 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
This is a fork of the Hprof Heap Dump parser that attempts to reduce memory
usage by performing multiple passes over the hprof file. The first pass loads
everything apart from the instance data, and the second pass loads the instance
data. This is not particularly elegant, but it works. The original docs are
included below.
----------------------
Hprof Heap Dump parser
Eddie Aftandilian ([email protected])
This is the source code for a parser for Hprof heap dump files that can
be produced by various JVMs. This code parses the binary format of these
files. Documentation on the file format and the meanings of the different
record types can be found here:
http://blogs.sun.com/kto/resource/manual.html (older documentation)
$JVM/demo/jvmti/hprof/src/manual.html (if you have the Sun JDK installed)
The main functionality is in the HprofParser.java file, which parses the heap
dump file and calls a method in the associated RecordHandler for each record
parsed. The RecordHandler interface is meant to be implemented to perform
whatever analysis you like. I recommend subclassing NullRecordHandler, which
does nothing for all records, and overriding only the methods for the record
types you are interested in. By default, the Parse program uses the example
PrintHandler, which simply prints the data from each record. To change to a
different handler class, simply pass the command line option
"--handler=<classname>" to Parse, where classname is the fully-qualified
class name of the handler class.
I provide a sample heap dump from Dacapo antlr in the file java.hprof.
The build uses Maven (http://maven.apache.org/). You can build it with the
following command:
$ maven compile
To produce a binary heap dump from the Oracle JVM, use the following command:
java -agentlib:hprof=heap=dump,format=b ToBeProfiledClass
This will dump the heap at the end of program execution. See the
documentation referenced above to see how to produce heap dumps at other
points in program execution.
This code is released under the Apache 2.0 license. See the LICENSE file in
this directory for details.