java hprof_java 性能之 hprof
JVM可以對java程序的cpu和heap進行 profiling。hprof 實際上是JVM中的一個native的庫,它會在JVM啟動的時候通過命令行參數來動態加載,并成為 JVM進程的一部分。
主要有兩種使用方式:
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.
默認情況下,hprof 出來的信息會寫入當前 classpath 目錄的?java.hprof.txt 文件中。
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的java hprof_java 性能之 hprof的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java webrtc ns降噪_单独编
- 下一篇: java socket 二次发送_发过2