基於動態連接庫實現,可用於性能分析,鎖內容.診斷memory leak問題等.
得到堆開闢信息
java -agentlib:hprof=heap=sites ToBeProfiledClass
幫助文檔
java -agentlib:hprof=help
- 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
format=b 選項不能夠和monitor=y,cpu=old|times共用
Use of the -Xrunhprof interface can still be used
-Xrunhprof依然可用.
java -Xrunhprof:[help]|[<option>=<value>, ...] 和 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.
默認下,堆信息輸出到當前工做目錄下的java.hprof.txt,在vm退出的時候生成.能夠經過設定dump on exit選項爲n來更改(doe=n)