JVMTI を利用したプロファイラエージェントで、ヒープや実行時間のプロファイリングなど基本的な機能が提供されている。
下記のコマンドでヘルプを見ることができる
java -agentlib:hprof=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
gc_okay=y|n
- 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
java -Xrunhprof:[help]|[<option>=<value>, ...] will behave exactly the same as: java -agentlib:hprof=[help]|[<option>=<value>, ...]
it is not an official product or formal part of the JDK.
in a future release.
http://apis.jpn.ph/fswiki/wiki.cgi?page=Java%2Fhprof%28jvmpi%29
http://lenemarix2.blog28.fc2.com/blog-entry-16.html
プロセス番号を調べてからつかいます。 自分はcygwinとかいれているので、
tasklist | nkf | grep java
とかで調べています。
バイナリファイルで結果を出力する例
jmap -dump:format=b,file=出力ファイルパス プロセス番号
出てきたファイルを見るには
jhat -J-Xmx700m jmapでの出力ファイルパス
以下紹介サイトより抜粋
詳しくは下記の紹介サイトをごらんください。
http://eclipse.org/mat/downloads.php
http://xiangcai.at.webry.info/201009/article_7.html
※現時点では、MATの更新サイトのアドレスがバージョンアップで変更になっていました。 http://download.eclipse.org/mat/1.2/update-site/