- 追加された行はこの色です。
- 削除された行はこの色です。
*目次 [#v4a08371]
#contents
*hprof [#tdc73634]
JVMTI を利用したプロファイラエージェントで、ヒープや実行時間のプロファイリングなど基本的な機能が提供されている。
*hprof を利用するには [#va5cd2b5]
-agentlib:hprof
*ヘルプの出し方 [#a6970211]
下記のコマンドでヘルプを見ることができる
java -agentlib:hprof=help
**何の略か [#n1494841]
HPROF: Heap and CPU Profiling Agent (JVMTI Demonstration Code)
**使い方 [#a15e46c5]
hprof usage: java -agentlib:hprof=[help]|[<option>=<value>, ...]
**オプション [#w9e640fd]
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 [#r5125362]
gc_okay=y|n
**例 [#u63e41f3]
- 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
**メモ [#d7bab5ca]
-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>, ...]
**注意 [#f3696783]
-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.
*日本語で紹介しているサイト [#t3d267f1]
**Java/hprof(jvmpi) [#gb27fe23]
http://apis.jpn.ph/fswiki/wiki.cgi?page=Java%2Fhprof%28jvmpi%29
**Javaでヒープダンプの取得/解析メモ その1 [#tb1a2e57]
http://lenemarix2.blog28.fc2.com/blog-entry-16.html
***jmap [#t6430fd8]
プロセス番号を調べてからつかいます。
自分はcygwinとかいれているので、
tasklist | nkf | grep java
とかで調べています。
バイナリファイルで結果を出力する例
jmap -dump:format=b,file=出力ファイルパス プロセス番号
出てきたファイルを見るには
jhat -J-Xmx700m jmapでの出力ファイルパス
*Eclipse Memory Analyzer [#v6473080]
以下紹介サイトより抜粋
-Leak Suspects - リークしてそうなのはこいつらだ
-Dominator tree - 大きいオブジェクトを一覧で見よう
-Path to GC Roots - こいつは誰が参照してる?
リークを特定する為の基本的な流れとしては、Leak Suspects で怪しいところを教えてもらい、Dominator Tree*1 で怪しいオブジェクトを一覧 & 構造を調べ、Path to GC Roots でリーク元を特定する、という様な流れになります。
詳しくは下記の紹介サイトをごらんください。
**公式サイト [#p1ef8d1f]
http://eclipse.org/mat/downloads.php
**インストール紹介サイト [#v912d614]
http://xiangcai.at.webry.info/201009/article_7.html
※現時点では、MATの更新サイトのアドレスがバージョンアップで変更になっていました。
http://download.eclipse.org/mat/1.2/update-site/
**紹介サイト [#cce1c24e]
http://tlync.hateblo.jp/entry/20111220/1324372308