java hprof_java 性能之 hprof
JVM可以對(duì)java程序的cpu和heap進(jìn)行 profiling。hprof 實(shí)際上是JVM中的一個(gè)native的庫(kù),它會(huì)在JVM啟動(dòng)的時(shí)候通過(guò)命令行參數(shù)來(lái)動(dòng)態(tài)加載,并成為 JVM進(jìn)程的一部分。
主要有兩種使用方式:
1.?java -agentlib:hprof=[:options] classname
2.?java -Xrunhprof[:options] classname
以下為 hprof 使用的幫助命令:
C:\Users\Administrator>java -agentlib:hprof=help
HPROF: Heap and CPU Profiling Agent (JVMTI Demonstration Code)
hprof usage: java -agentlib:hprof=[help]|[=, ...]
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= ? ? ? ? ? ?write data to file ? ? ? ? ? ? java.hprof[{.txt}]
net=: ? ? ?send data over a socket ? ? ? ?off
depth= ? ? ? ? ? stack trace depth ? ? ? ? ? ? ?4
interval= ? ? ? ? ?sample interval in ms ? ? ? ? ?10
cutoff= ? ? ? ? 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 ? ? ? ? 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]|[=, ...]
will behave exactly the same as:
java -agentlib:hprof=[help]|[=, ...]
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.
默認(rèn)情況下,hprof 出來(lái)的信息會(huì)寫入當(dāng)前 classpath 目錄的?java.hprof.txt 文件中。
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的java hprof_java 性能之 hprof的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: java webrtc ns降噪_单独编
- 下一篇: bootstrap 图片轮询_消息通知功