HPORF is actually used to work out which parts of a program
are using the most memory or processor time.
To improve the efficiency of our application we should know what part of
the code are using large amount of memory and CPU resource.
HPROF is actually a JVM native agent library which is
dynamically loaded through a command line option, at JVM startup, and becomes
part of the JVM process. By supplying
HPROF options at startup, users can request various types of heap and CPU
profiling features. The data generated
can be in textual or binary format, and can be used to track down and isolate
performance problems involving memory usage and inefficient code.
Java –Xrunhprof[<option>=<value>,…]
<classname>
When we run Java with HPROF, an output file is created at
the end of program execution. This file
is placed in the current working directory and is called java.hprof.txt
(java.hprof if binary format is used) unless a different filename has been
given. This file contains a number of
different sections, but the exact format and content depend on the selected
options.
The command java –Xrunhprof:help display the options
avaialbe
D:\KalGyan>java
-Xrunhprof:help
HPROF: Heap and CPU Profiling Agent (JVMTI
Demonstration Code)
hprof
usage: java -agentlib:hprof=[help]|[<option>=<value>, ...]
Option
Name and Value Description Default
--------------------- ----------- -------
heap=dump|sites|all heap profiling all
cpu=samples|times|old CPU usage off
monitor=y|n monitor contention n
format=a|b text(txt) or binary output a
file=<file> write data to file java.hprof[{.txt}]
net=<host>:<port> send data over a socket off
depth=<size> stack trace depth 4
interval=<ms> sample interval in ms 10
cutoff=<value> output cutoff point 0.0001
lineno=y|n line number in traces? y
thread=y|n thread in traces? n
doe=y|n dump on exit? y
msa=y|n Solaris micro state accounting
n
force=y|n force output to <file> y
verbose=y|n print messages about dumps y
Obsolete
Options
----------------
gc_okay=y|n
Examples
--------
- Get sample cpu information every 20
millisec, with a stack depth of 3:
java
-agentlib:hprof=cpu=samples,interval=20,depth=3 classname
- Get heap usage information based on the
allocation sites:
java -agentlib:hprof=heap=sites classname
Notes
-----
- The option format=b cannot be used with
monitor=y.
- The option format=b cannot be used with
cpu=old|times.
- Use of the -Xrunhprof interface can still
be used, e.g.
java
-Xrunhprof:[help]|[<option>=<value>, ...]
will behave exactly the same as:
java
-agentlib:hprof=[help]|[<option>=<value>, ...]
Warnings
--------
- This is demonstration code for the JVMTI interface
and use of BCI,
it is not an official product or formal
part of the JDK.
- The -Xrunhprof interface will be removed in
a future release.
- The option format=b is considered
experimental, this format may change
in a future release.
heap=dump|sites|all
This
option helps in the analysis of memeory usage.
It tells HPROF to generate stack traces, from which we can see where
memory was allocated. If we use the
heap=dump option, we get a dump of all reachable objects in the heap. With heap=sites, we get a sorted list of
sites with the most heavily allocated objects at the top.
cpu=samples|times|old
The
cpu option outputs information that is useful in determining where the CPU
spends most of its time. If cpu is set
to “samples”, the JVM pauses execution and identifies which method call is
active. If the sampling rate is high
enough, we get a good picture o where our program spends most of its time. If cpu is set to “timing”, we receive precise
measurements of how many times each method was called and how long each
execution took. Although this is more
accurate, it slows down the program. If
cpu is set to “old” the profiling data is output in the old hprof format.
monitor=y|n
The
monitor option can help us to understand how synchronization affects the
performance of our application. Monitors
are used to implement thread synchronization so getting information on monitors
can tell us how much time different threads are spending when trying to access resources
that are already locked. HPROF also give
us a snapshot of the monitors in use and it is useful for detecting deadlocks.
format= a|b
The
default is for the output file to be in ASCII format. Set format to ‘b’ if we want to specify a
binary format.
file =<filename>
The
file option lets us change the name of the output file. The default name for an ASCII file is java.hprof.txt. The default name for a binary files is
java.hprof
net=<host>:<port>
To
send the output over the network rather than to local file we can use this net
option.
depth=<size>
The
depth option indicates the number of method frames to display in a stack trace
thread =y | n
If
we set the thread option to ‘y’ then the thread id is preinted besided each
trace. This option is useful if it is
not clear which thread is associated with which trace. This can be an issue in a multi-threaded
application.
doe= y | n
The
default beavhiour is to collect profile information when an application
exits. To collect the profiling data
during executing we set doe (dump on exit) to ‘n’.
Let
see few examples on the HPROF with their options
Heap allocation profile
(heap=sites)
Command
used: javac -J-agentlib:hprof=heap=sites TestKalGayn.java
SITES BEGIN (ordered by live bytes) Fri Oct 22 11:52:24 2004
percent live alloc'ed stack class
rank self accum bytes objs bytes objs trace name
1 44.73% 44.73% 1161280 14516 1161280 14516 302032 java.util.zip.ZipEntry
2 8.95% 53.67% 232256 14516 232256 14516 302033 com.sun.tools.javac.util.List
3 5.06% 58.74% 131504 2 131504 2 301029 com.sun.tools.javac.util.Name[]
4 5.05% 63.79% 131088 1 131088 1 301030 byte[]
5 5.05% 68.84% 131072 1 131072 1 301710 byte[]
SITES BEGIN (ordered by live bytes) Fri Oct 22 11:52:24 2004
percent live alloc'ed stack class
rank self accum bytes objs bytes objs trace name
1 44.73% 44.73% 1161280 14516 1161280 14516 302032 java.util.zip.ZipEntry
2 8.95% 53.67% 232256 14516 232256 14516 302033 com.sun.tools.javac.util.List
3 5.06% 58.74% 131504 2 131504 2 301029 com.sun.tools.javac.util.Name[]
4 5.05% 63.79% 131088 1 131088 1 301030 byte[]
5 5.05% 68.84% 131072 1 131072 1 301710 byte[]
When java.hprof.txt file is generated
when stack will appear in this way:
TRACE 302032:
java.util.zip.ZipEntry.<init>(ZipEntry.java:101)
java.util.zip.ZipFile$3.nextElement(ZipFile.java:435)
java.util.zip.ZipFile$3.nextElement(ZipFile.java:413)
com.sun.tools.javac.jvm.ClassReader.openArchive(ClassReader.java:1442)
TRACE 302033:
com.sun.tools.javac.util.List.<init>(List.java:43)
com.sun.tools.javac.util.List.<init>(List.java:51)
com.sun.tools.javac.util.ListBuffer.append(ListBuffer.java:98)
com.sun.tools.javac.jvm.ClassReader.openArchive(ClassReader.java:1442)
If we want to create dump file then we
will go with following command
Command used: javac -J-agentlib:hprof=heap=dump TestKalGayn.java
To get CPU sampling profiles
(cpu=samples)
Command used: javac -J-agentlib:hprof=cpu=samples TestKalGyan.java
CPU SAMPLES BEGIN (total = 126) Fri Oct 22 12:12:14 2004
rank self accum count trace method
1 53.17% 53.17% 67 300027 java.util.zip.ZipFile.getEntry
2 17.46% 70.63% 22 300135 java.util.zip.ZipFile.getNextEntry
3 5.56% 76.19% 7 300111 java.lang.ClassLoader.defineClass2
4 3.97% 80.16% 5 300140 java.io.UnixFileSystem.list
5 2.38% 82.54% 3 300149 java.lang.Shutdown.halt0
6 1.59% 84.13% 2 300136 java.util.zip.ZipEntry.initFields
7 1.59% 85.71% 2 300138 java.lang.String.substring
8 1.59% 87.30% 2 300026 java.util.zip.ZipFile.open
9 0.79% 88.10% 1 300118 com.sun.tools.javac.code.Type$ErrorType.<init>
10 0.79% 88.89% 1 300134 java.util.zip.ZipFile.ensureOpen
To get CPU usage time profile
(cpu=times)
Command used: javac -J-agentlib:hprof=cpu=times TestKalGayn.java
CPU TIME (ms) BEGIN (total = 103099259) Fri Oct 22 12:21:23 2004
rank self accum count trace method
1 5.28% 5.28% 1 308128 com.sun.tools.javac.Main.compile
2 5.16% 10.43% 1 308127 com.sun.tools.javac.main.Main.compile
3 5.15% 15.58% 1 308126 com.sun.tools.javac.main.Main.compile
4 4.07% 19.66% 1 308060 com.sun.tools.javac.main.JavaCompiler.compile
5 3.90% 23.56% 1 306652 com.sun.tools.javac.comp.Enter.main
6 3.90% 27.46% 1 306651 com.sun.tools.javac.comp.Enter.complete
7 3.74% 31.21% 4 305626 com.sun.tools.javac.jvm.ClassReader.listAll
8 3.74% 34.95% 18 305625 com.sun.tools.javac.jvm.ClassReader.list
9 3.24% 38.18% 1 305831 com.sun.tools.javac.comp.Enter.classEnter
10 3.24% 41.42% 1 305827 com.sun.tools.javac.comp.Enter.classEnter
11 3.24% 44.65% 1 305826 com.sun.tools.javac.tree.Tree$TopLevel.accept
12 3.24% 47.89% 1 305825 com.sun.tools.javac.comp.Enter.visitTopLevel
13 3.23% 51.12% 1 305725 com.sun.tools.javac.code.Symbol.complete
14 3.23% 54.34% 1 305724 com.sun.tools.javac.jvm.ClassReader.complete
15 3.23% 57.57% 1 305722 com.sun.tools.javac.jvm.ClassReader.fillIn
16 1.91% 59.47% 16 305611 com.sun.tools.javac.jvm.ClassReader.openArchive
17 1.30% 60.78% 330 300051 java.lang.ClassLoader.loadClass
18 1.28% 62.06% 330 300050 java.lang.ClassLoader.loadClass
19 1.22% 63.28% 512 300695 java.net.URLClassLoader.findClass
20 1.21% 64.48% 512 300693 java.net.URLClassLoader$1.run
21 1.09% 65.57% 14516 305575 java.util.zip.ZipFile$3.nextElement
22 0.98% 66.55% 14516 305574 java.util.zip.ZipFile$3.nextElement
23 0.96% 67.52% 1 304560 com.sun.tools.javac.main.JavaCompiler.instance
24 0.96% 68.48% 1 304559 com.sun.tools.javac.main.JavaCompiler.<init>
25 0.71% 69.19% 256 302078 java.net.URLClassLoader.access$100
17 Comments
10 YouTube videos about boxing - Videodl.cc
ReplyDeleteWatch the full video youtube to mp3 about boxing. YouTube videos about boxing. Get the best video about boxing. youtube.videos.usatoday.com.
https://bayanlarsitesi.com/
ReplyDeleteEskişehir
Erzincan
Ardahan
Erzurum
KWV
van
ReplyDeletekastamonu
elazığ
tokat
sakarya
NJKCHX
whatsapp görüntülü show
ReplyDeleteücretli.show
NZİ
FE328
ReplyDeleteGümüşhane Parça Eşya Taşıma
Ardahan Şehirler Arası Nakliyat
Bitlis Şehirler Arası Nakliyat
Çerkezköy Organizasyon
Yozgat Parça Eşya Taşıma
Giresun Şehir İçi Nakliyat
Karaman Parça Eşya Taşıma
Sakarya Şehir İçi Nakliyat
Çerkezköy Motor Ustası
ED2B7
ReplyDelete%20 indirim kodu
5EBBF
ReplyDeletemobil sohbet sitesi
sohbet muhabbet
afyon görüntülü sohbet siteleri ücretsiz
hakkari görüntülü sohbet siteleri
görüntülü sohbet ücretsiz
denizli canlı sohbet et
gümüşhane sesli sohbet sitesi
kadınlarla görüntülü sohbet
sinop rastgele sohbet
4A85F
ReplyDeleteGörüntülü Sohbet
Kripto Para Üretme Siteleri
Tiktok Takipçi Hilesi
Instagram Beğeni Satın Al
Aion Coin Hangi Borsada
Qlc Coin Hangi Borsada
Bitcoin Nedir
Kripto Para Nasıl Kazılır
Likee App Takipçi Hilesi
1CB03
ReplyDeletepoloniex
en düşük komisyonlu kripto borsası
canlı sohbet uygulamaları
papaya
referans kodu binance
bitmex
okex
kripto para haram mı
binance 100 dolar
80FB5
ReplyDeleteOctober 2024 Calendar
March 2024 Calendar
bitmex
binance
June 2024 Calendar
okex
bitexen
bitcoin nasıl oynanır
coinex
E4C929E86D
ReplyDeletedegra
viga
geciktirici
vega
delay
yapay kızlık zarı
vigrande
sildegra
bufalo içecek
CA38B7FDD7
ReplyDeletenovagra
performans arttırıcı
telegram show
bayan azdırıcı damla
vega
themra macun
ücretli şov
sinegra
viga
6713B56A81
ReplyDeletebufalo içecek
fx15
kamagra
telegram show
sertleştirici
vega
yapay kızlık zarı
whatsapp ücretli show
cam şov
8FDDAB76A3
ReplyDeleteereksiyon hapı
telegram görüntülü şov
whatsapp görüntülü şov
green temptation
stag
bayan azdırıcı damla
degra
viagra
ücretli şov
D17F42F1C0
ReplyDeletesildegra
lady era hap
performans arttırıcı
degra 100 mg
whatsapp görüntülü şov
telegram görüntülü şov
delay
ereksiyon hapı
bayan azdırıcı damla
B51C411EC1
ReplyDeletedelay
görüntülü show
bufalo içecek
bufalo çikolata
fx15 zayıflama hapı
ereksiyon hapı
cam show
telegram görüntülü şov
viga
6AC27141F5
ReplyDeleteinstagram ucuz beğeni