Maven构建中的“java.lang.OutOfMemoryError:PermGen space”
可能重复:
如何处理“java.lang.OutOfMemoryError:PermGen space”错误
我在构建Maven项目时遇到了这个错误,我增加了MAVEN_OPTS,但都是一样的,我发现了一些类似的帖子,但他们引用了其他内容。 我该如何解决?
The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.compiler.javac.IsolatedClassLoader.loadClass(IsolatedClassLoader.java:56)
at com.sun.tools.javac.comp.Annotate.<init>(Annotate.java:52)
at com.sun.tools.javac.comp.Annotate.instance(Annotate.java:36)
at com.sun.tools.javac.jvm.ClassReader.<init>(ClassReader.java:215)
at com.sun.tools.javac.jvm.ClassReader.instance(ClassReader.java:168)
at com.sun.tools.javac.main.JavaCompiler.<init>(JavaCompiler.java:293)
at com.sun.tools.javac.main.JavaCompiler.instance(JavaCompiler.java:72)
at com.sun.tools.javac.main.Main.compile(Main.java:340)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:420)
at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:141)
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:493)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
当你说你增加了MAVEN_OPTS
,你增加了什么值? 您是否增加了MaxPermSize
,例如:
export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"
(或在Windows上:)
set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m
如果你想为可重复构建构建POM的这一部分,你可以使用一些插件的fork-variant(尤其是compiler:compile和surefire:test):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>1024m</maxmem>
<compilerArgs>
<arg>-XX:MaxPermSize=256m</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<forkCount>1</forkCount>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
当然,请增加烫发空间的大小。 使用-XX:MaxPermSize=128m
选项。 将该值设置为适当的值。
上一篇: "java.lang.OutOfMemoryError: PermGen space" in Maven build
下一篇: Error java.lang.OutOfMemoryError: GC overhead limit exceeded