java.lang.OutOfMemoryError:PermGen 空间错误 [重复]

Posted

技术标签:

【中文标题】java.lang.OutOfMemoryError:PermGen 空间错误 [重复]【英文标题】:java.lang.OutOfMemoryError: PermGen space error [duplicate] 【发布时间】:2012-09-16 03:02:44 【问题描述】:

我已经阅读了各种解决方案。 link 在

的评论中

Dealing with “java.lang.OutOfMemoryError: PermGen space” error

是迄今为止我发现的最好的。不过,这很复杂。

关键是,我在使用 Maven 编译项目时遇到此错误。

据我所知,目前还没有应用服务器。那么发生了什么事?

我能做什么?

这是我的错误:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:02.743s
[INFO] Finished at: Mon Sep 24 17:48:50 CEST 2012
[INFO] Final Memory: 77M/894M
[INFO] ------------------------------------------------------------------------
---------------------------------------------------
constituent[0]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/aether-a
pi-1.13.1.jar
constituent[1]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/aether-c
onnector-wagon-1.13.1.jar
constituent[2]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/aether-i
mpl-1.13.1.jar
constituent[3]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/aether-s
pi-1.13.1.jar
constituent[4]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/aether-u
til-1.13.1.jar
constituent[5]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/commons-
cli-1.2.jar
constituent[6]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-ae
ther-provider-3.0.4.jar
constituent[7]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-ar
tifact-3.0.4.jar
constituent[8]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-co
mpat-3.0.4.jar
constituent[9]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-co
re-3.0.4.jar
constituent[10]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-e
mbedder-3.0.4.jar
constituent[11]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-m
odel-3.0.4.jar
constituent[12]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-m
odel-builder-3.0.4.jar
constituent[13]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-p
lugin-api-3.0.4.jar
constituent[14]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-r
epository-metadata-3.0.4.jar
constituent[15]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-s
ettings-3.0.4.jar
constituent[16]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/maven-s
ettings-builder-3.0.4.jar
constituent[17]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/plexus-
cipher-1.7.jar
constituent[18]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/plexus-
component-annotations-1.5.5.jar
constituent[19]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/plexus-
interpolation-1.14.jar
constituent[20]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/plexus-
sec-dispatcher-1.3.jar
constituent[21]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/plexus-
utils-2.0.6.jar
constituent[22]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/sisu-gu
ava-0.9.9.jar
constituent[23]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/sisu-gu
ice-3.1.0-no_aop.jar
constituent[24]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/sisu-in
ject-bean-2.3.0.jar
constituent[25]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/sisu-in
ject-plexus-2.3.0.jar
constituent[26]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/wagon-f
ile-2.2.jar
constituent[27]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/wagon-h
ttp-2.2-shaded.jar
constituent[28]: file:/C:/Program%20Files%20(x86)/apache-maven-3.0.4/lib/wagon-p
rovider-api-2.2.jar
---------------------------------------------------
Exception in thread "main" java.lang.OutOfMemoryError: PermGen space

【问题讨论】:

【参考方案1】:

请看这个问题: "java.lang.OutOfMemoryError: PermGen space" in Maven build

(或)

请看这个链接: http://vikashazrati.wordpress.com/2007/07/26/quicktip-how-to-increase-the-java-heap-memory-for-maven-2-on-linux/

如果你在做 mvn 站点时遇到 OutOfMemory 错误,因为 您生成的所有报告,只需增加堆大小 对于 Maven2。在 linux 上执行此操作的方法。

在你的 mvn.sh 中添加这个作为版权后的第一行和 其他cmets。

导出 MAVEN_OPTS="-Xmx512m"

注意,从 Maven 2.0.6 开始,一些用户报告说双 引号会出现问题,因此您可能需要使用

导出 MAVEN_OPTS=-Xmx512m

【讨论】:

set MAVEN_OPTS="-Xmx512m" 在 Windows 上为我工作 在mac osx上,我也需要设置-XX:MaxPermSize,即。 export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"

以上是关于java.lang.OutOfMemoryError:PermGen 空间错误 [重复]的主要内容,如果未能解决你的问题,请参考以下文章