有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java HPROF在试图查找Maven build内存泄漏时发出抱怨

我有一个Maven构建,它似乎偶尔会出现漏洞,导致Java进程耗尽PermGen内存(编辑),我从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_选项看起来像

MAVEN_OPTS=-agentlib:hprof=format=b

这是“mvn清洁”的结果

[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

从这里开始最好的方式是什么


共 (1) 个答案

  1. # 1 楼答案

    当从32位jvm切换到64位jvm时,典型的问题是PermGen异常

    使用64位JVM时,需要更大的PermGen大小。 如果需要,尝试使用MAVEN_OPTS="-XX:MaxPermSize=256m"或更高版本

    在使用64位jvm构建大型项目时,我个人通常使用512m甚至1g。 同样的项目需要32位JMV的一半