LoginSignup
10
12

More than 5 years have passed since last update.

PrintClassHistogramでヒープリーク調査

Last updated at Posted at 2013-04-12

Oracle JDK のPrintClassHistogramオプションを使うと、ヒープの統計情報を出力することが出来るので、Mapが膨らんでいくようなメモリリークをしているときの調査に役立ちます。ただし、出力時にフルGCが走るので、Old 領域のフルGCによる Stop the World が問題になっているような場合および、Perm領域のリークには有効ではありません。

まず、JVM起動オプションに以下の設定を追加します。

-verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintClassHistogram

その上で、JVMの起動ユーザーないしrootで、以下のコマンドを定期的に実行します

/usr/local/java/bin/jps  |grep -v Jps |grep -v Hoge |awk '{print $1}' |xargs kill -3

grepのフィルタリングは適宜調整してください。
出力は標準出力(Tomcatならcatalina.out)に出力されます。

10
12
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
12