私は、Java プロセスが PermGen メモリ (EDIT) を使い果たすことがあるリークがあるように見える Maven ビルドを持っています。VisualVM から、新しいビルドが行われるたびにヒープと PermGen が著しく増加することを学びました。ここで、リークがどこにあるかを調べたいと思います(編集:時折の例外を取り除くだけではありません)。
これに対する標準的なアプローチは、HPROF に事後分析用のデータを収集させることです。ただし、これは失敗し、生成された java.hprof ファイルはツールで正しく解析できません。
私の「mvn.bat」ファイルは次のようになります (Windows 7 の 64 ビット JVM):
set JAVA_HOME=c:\Program Files\java\jdk1.7.0_11
C:\Users\TRA\progs\apache-maven-3.0.4\bin\mvn %*
私の MAVEN_OPTS は次のようになります
MAVEN_OPTS=-agentlib:hprof=format=b
これは「mvn clean」の結果です。
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.589s
[INFO] Finished at: Fri Feb 08 12:46:26 CET 2013
[INFO] Final Memory: 8M/154M
[INFO] ------------------------------------------------------------------------
Dumping Java heap ...
HPROF LIST OF ALL FIELDS:
[1] Lsun/reflect/UnsafeFieldAccessorImpl; "field" "Ljava/lang/reflect/Field;"(ty=OBJ) val=[0x00000000,0x500007e0] or [0x00000000,0x500007e0]
[2] Lsun/reflect/UnsafeFieldAccessorImpl; "fieldOffset" "I" (primType=73(I)) val=[0x00000007,0x00000070] or [0x00000007,0x00000070]
[3] Lsun/reflect/UnsafeFieldAccessorImpl; "isFinal" "Z" (primType=90(Z)) val=[0x00000007,0x7ae16501] or [0x00000007,0x7ae16501]
[4] Lsun/reflect/UnsafeStaticFieldAccessorImpl; "base" "Ljava/lang/Object;"(ty=OBJ)
[5] Lsun/reflect/UnsafeQualifiedStaticFieldAccessorImpl; "isReadOnly" "Z" (primType=90(Z))
FOLLOW REFERENCES RETURNED:
[1]: flavor=1, refKind=2, primType=0, object_index=0x500007e0, length=-1, next=0xb0013852
[2]: flavor=2, refKind=2, primType=73, object_index=0x0, length=-1, next=0xb0013851
[3]: flavor=2, refKind=2, primType=90, object_index=0x0, length=-1, next=0xb0013850
[4]: flavor=2, refKind=2, primType=90, object_index=0x0, length=-1, next=0x0
PROBLEM WITH:
[4] Lsun/reflect/UnsafeStaticFieldAccessorImpl; "base" "Ljava/lang/Object;" (primType=0( ), got 90(Z)) val=[0x00000007,0x7ae16501] or [0x00000000,0x00000000]
HPROF ERROR: Trouble with fields and heap data [hprof_reference.c:281]
HPROF LIST OF ALL FIELDS:
[1] Lsun/reflect/UnsafeFieldAccessorImpl; "field" "Ljava/lang/reflect/Field;"(ty=OBJ) val=[0x00000000,0x500007e1] or [0x00000000,0x500007e1]
[2] Lsun/reflect/UnsafeFieldAccessorImpl; "fieldOffset" "I" (primType=73(I)) val=[0x00000007,0x00000074] or [0x00000007,0x00000074]
[3] Lsun/reflect/UnsafeFieldAccessorImpl; "isFinal" "Z" (primType=90(Z)) val=[0x00000007,0x7b2c1001] or [0x00000007,0x7b2c1001]
[4] Lsun/reflect/UnsafeStaticFieldAccessorImpl; "base" "Ljava/lang/Object;"(ty=OBJ)
[5] Lsun/reflect/UnsafeQualifiedStaticFieldAccessorImpl; "isReadOnly" "Z" (primType=90(Z))
FOLLOW REFERENCES RETURNED:
[1]: flavor=1, refKind=2, primType=0, object_index=0x500007e1, length=-1, next=0xb0013836
[2]: flavor=2, refKind=2, primType=73, object_index=0x0, length=-1, next=0xb0013835
[3]: flavor=2, refKind=2, primType=90, object_index=0x0, length=-1, next=0xb0013834
[4]: flavor=2, refKind=2, primType=90, object_index=0x0, length=-1, next=0x0
PROBLEM WITH:
[4] Lsun/reflect/UnsafeStaticFieldAccessorImpl; "base" "Ljava/lang/Object;" (primType=0( ), got 90(Z)) val=[0x00000007,0x7b2c1001] or [0x00000000,0x00000000]
HPROF ERROR: Trouble with fields and heap data [hprof_reference.c:281]
HPROF LIST OF ALL FIELDS:
[1] Lsun/reflect/UnsafeFieldAccessorImpl; "field" "Ljava/lang/reflect/Field;"(ty=OBJ) val=[0x00000000,0x5002f4a1] or [0x00000000,0x5002f4a1]
[2] Lsun/reflect/UnsafeFieldAccessorImpl; "fieldOffset" "I" (primType=73(I)) val=[0x00000007,0x00000070] or [0x00000007,0x00000070]
[3] Lsun/reflect/UnsafeFieldAccessorImpl; "isFinal" "Z" (primType=90(Z)) val=[0x00000007,0x7ae16501] or [0x00000007,0x7ae16501]
[4] Lsun/reflect/UnsafeStaticFieldAccessorImpl; "base" "Ljava/lang/Object;"(ty=OBJ)
[5] Lsun/reflect/UnsafeQualifiedStaticFieldAccessorImpl; "isReadOnly" "Z" (primType=90(Z))
FOLLOW REFERENCES RETURNED:
[1]: flavor=1, refKind=2, primType=0, object_index=0x5002f4a1, length=-1, next=0xb0013a4b
[2]: flavor=2, refKind=2, primType=73, object_index=0x0, length=-1, next=0xb0013a4a
[3]: flavor=2, refKind=2, primType=90, object_index=0x0, length=-1, next=0xb0013a49
[4]: flavor=2, refKind=2, primType=90, object_index=0x0, length=-1, next=0x0
(そして何度も)。私はhprofに慣れていません。
ここから先に進む最善の方法は何ですか?