CLS50000006(name=java.lang.annotation.Annotation,trace=300000)
loader90000001
OBJ50000114(sz=96,trace=300001,class=java.lang.Thread@50000106)
name50000116
group50008c6c
contextClassLoader50008c53
inheritedAccessControlContext50008c79
blockerLock50000115
OBJ50008c6c(sz=48,trace=300000,class=java.lang.ThreadGroup@50000068)
name50008c7d
threads50008c7c
groups50008c7b
ARR50008c6f(sz=16,trace=300000,nelems=1,
elemtype=java.lang.String[]@5000008e)
[0]500007a5
CLS5000008e(name=java.lang.String[],trace=300000)
super50000012
loader90000001
:
HEAPDUMPEND
EachrecordisaROOT,OBJ,CLS,orARR torepresent a root, anobject instance,a class,or anarray. The hexadecimal
numbers are identiiers assigned by HPROF. These numbers are used to show the references from an object to
another object. For example,in the above sample, the java.lang.Thread instance 50000114 has a reference to its
threadgroup(50008c6c)andotherobjects.
Ingeneral,astheoutputisverylarge,itisnecessarytouseatooltovisualizeorprocesstheoutputofaheapdump.
Onesuchtoolisjhat.See 2.5jhatUtility.
2.1.3CPUUsageSamplingProiles(cpu=samples)
TheHPROFtoolcancollectCPUusageinformationbysamplingthreads.Belowispartoftheoutputcollectedfroma
runofthejavaccompiler.
$javac‐J‐agentlib:hprof=cpu=samplesHello.java
CPUSAMPLESBEGIN(total=462)WedOct413:33:072006
rankselfaccumcounttracemethod
149.57%49.57%229300187java.util.zip.ZipFile.getNextEntry
26.93%56.49%32300190java.util.zip.ZipEntry.initFields
34.76%61.26%22300122java.lang.ClassLoader.defineClass2
42.81%64.07%13300188java.util.zip.ZipFile.freeEntry
51.95%66.02%9300129java.util.Vector.addElement
61.73%67.75%8300124java.util.zip.ZipFile.getEntry
71.52%69.26%7300125java.lang.ClassLoader.findBootstrapClass
80.87%70.13%4300172com.sun.tools.javac.main.JavaCompiler.<init>
90.65%70.78%3300030java.util.zip.ZipFile.open
100.65%71.43%3300175com.sun.tools.javac.main.JavaCompiler.<init>
...
CPUSAMPLESEND
TheHPROFagent periodicallysamples thestackof all runningthreadstorecord themostfrequentlyactive stack
traces.Thecountieldaboveindicateshowmanytimesaparticularstacktracewasfoundtobeactive.Thesestack
tracescorrespondtotheCPUusagehotspotsintheapplication.
2.1.4CPUUsageTimesProile(cpu=times)
The HPROF tool can collect CPU usage information by injecting code into every method entry and exit, thereby
keepingtrackofexactmethodcallcountsandthetimespentineachmethod.ThisprocessusesByteCodeInjection
(BCI)andrunsconsiderablyslowerthanthecpu=samplesoption.Belowispartoftheoutputcollectedfromarunof
thejavaccompiler.
$javac‐J‐agentlib:hprof=cpu=timesHello.java
CPUTIME(ms)BEGIN(total=2082665289)Wedoct413:43:422006
rankselfaccumcounttracemethod
13.70%3.70%1311243com.sun.tools.javac.Main.compile
23.64%7.34%1311242com.sun.tools.javac.main.Main.compile
33.64%10.97%1311241com.sun.tools.javac.main.Main.compile
43.11%14.08%1311173com.sun.tools.javac.main.JavaCompiler.compile