Maven Out of Memory Build Failure

前端 未结 13 1091
情歌与酒
情歌与酒 2020-11-29 18:37

As of today, my maven compile fails.

[INFO] [ERROR] Unexpected
[INFO] java.lang.OutOfMemoryError: Java heap space
[INFO]  at java.util.Arrays.copyOfRange(Arr         


        
相关标签:
13条回答
  • 2020-11-29 19:39

    What kind of 'web' module are you talking about? Is it a simple war and has packaging type war?

    If you are not using Google's web toolkit (GWT) then you don't need to provide any gwt.extraJvmArgs

    Forking the compile process might be not the best idea, because it starts a second process which ignores MAVEN_OPTS altogether, thus making analysis more difficult.

    So I would try to increase the Xmx by setting the MAVEN_OPTS

    export MAVEN_OPTS="-Xmx3000m"
    

    And don't fork the compiler to a different process

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.5</source>
            <target>1.5</target>
       </configuration>
    </plugin>
    

    Increasing -XX:MaxPermSize=512m should not be required because if perm size is the reason of the problem, then I would expect the error java.lang.OutOfMemoryError: PermGen space

    If that does not solve your problem, then you can create heap dumps for further analysis by adding -XX:+HeapDumpOnOutOfMemoryError. Additionally, you can use jconsole.exe in your java bin directory to connect to the jvm while the compilation is running and see what is going on inside the jvm's heap.

    Another Idea (may be a stupid one) which came up to me, do you have enough RAM inside your machine? Defining the memory size is nice, but if your host has only 4GB and then you might have the problem that Java is not able to use the defined Memory because it is already used by the OS, Java, MS-Office...

    0 讨论(0)
提交回复
热议问题