メモリーリーク調査

Javaでローカルのアプリケーションを作成時、メモリーリークを調査したときの記録

用意するアプリ

・GCViewer (時間毎のメモリの使用量を確認)
・Memory Analyzer (ヒープダンプを解析)

GCViewer 1.29 インストール

ダウンロード先:http://www.tagtraum.com/gcviewer-download.html


Memory Analyzer 0.8 インストール

ダウンロード先:http://www.eclipse.org/mat/

使用方法

GCViewer
GCログファイルを出力後、GCViewerで確認

Java起動オプションに以下を追加
 -Xloggc:C:\gclog.txt -verbose:gc


出力されたgclog.txtをGCViewerで表示




Memory Analyzer
ヒープダンプを出力後、Memory Analyzerで確認

コマンドプロンプトで以下を実行

C:\work>jps
123 Jps
4567 Sample


C:\work>jmap -dump:format=b,file=heap.map 4567



出力されたheap.mapをMemory Analyzerで表示