web-dev-qa-db-ja.com

Mavenビルドの「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)
182

MAVEN_OPTSを増やしたと言うとき、どの値を増やしましたか?例のように、MaxPermSizeを増やしましたか?

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"

(またはWindowsの場合:)

set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m
306
Arun R

繰り返し可能なビルドのためにPOMのこの部分を作りたい場合は、いくつかのプラグインのフォークバリアントを使用できます(特に 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>
23
eckes

もちろん、パーマ空間のサイズを増やします。 -XX:MaxPermSize=128mオプションを使用します。値を適切な値に設定します。

16
duffymo

この非常に迷惑なエラーなので、私がしたこと:Windowsの場合:

Edit system environment variables - > Edit Variables -> New

次に記入

MAVEN_OPTS
-Xms512m -Xmx2048m -XX:MaxPermSize=512m

enter image description here

次に、コンソールを再起動して、mavenビルドを再度実行します。 Mavenスペース/パーマサイズの問題はもうありません。

1
Xelian

この例外が発生したとき、以下の図に示すように、「実行構成...」パネルを使用してこれを解決しました。特に、JREタブでは、VM引数が重要です
"-Xmx1024m -Xms512m -XX:MaxPermSize = 1024m -XX:PermSize = 512m")。

enter image description here

1
ÖMER TAŞCI

パーマネントジェネレーションヒープがいっぱいになり、コマンドプロンプトを使用してWindowsでMavenプロジェクトをビルドするときに、このエラーに直面します。ヒープサイズを増やす必要があるため、環境変数@ ControlPanel/SystemおよびSecurity/Systemを設定し、そこでChange settingをクリックして選択します。環境変数を次のように設定します

  • 変数名:MAVEN_OPTS
  • 変数値:-XX:MaxPermSize = 128m
0
Ranjit

Mavenビルドエラーで「Java.lang.OutOfMemoryError:PermGen space」のgit mvn clean installを使用してwarをビルドしようとすると、git bashコマンドのソリューションが見つかりました

use below command first 

$ export MAVEN_OPTS="-Xmx512m -Xss32m"

then use your mvn command to clean install /build war file

$ mvn clean install

NOTE: you don't need -XX:MaxPermSize argument in MAVEN_OPTS when your are using jdk1.8
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=XXXm; support was removed in 8.0
0
mkumar0304