Maven throws “java.lang.OutOfMemoryError”

2019-01-17 06:07发布

I'm compiling an open source project with "mvn install" but ended up with java.lang.OutOfMemoryError: Java heap space. I tried to execute java -Xmx256m but the output was java synopsis which indicated it's an invalid command.

I'm using jdk1.5.0_08, any ideas why this is happening?

Thanks,

9条回答
我只想做你的唯一
2楼-- · 2019-01-17 06:32

Not only heap memory. You have to increase perm size also to resolve that exception in maven use these variables in environment variable.

variable name: MAVEN_OPTS
variable value: -Xmx512m -XX:MaxPermSize=256m

查看更多
混吃等死
3楼-- · 2019-01-17 06:36

Set the environment variable:

MAVEN_OPTS="-Xmx512m"
查看更多
Bombasti
4楼-- · 2019-01-17 06:40

Alternatively use set MAVEN_OPTS="-XX:MaxPermSize=256m" while running from command prompt.

查看更多
时光不老,我们不散
5楼-- · 2019-01-17 06:41

Try to change or update your Maven install. I had this problem but I solved it by upgrading Maven (3.0.5 to 3.3.3).

查看更多
霸刀☆藐视天下
6楼-- · 2019-01-17 06:45

It depends on which JVM instance require more memory. As example, if tests are forked (by default), and fails due OutOfMemoryError then try configure plugin which launching them:

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <argLine>-Xmx1024m</argLine>
            </configuration>
        </plugin>
查看更多
Emotional °昔
7楼-- · 2019-01-17 06:46

on a Unix-like system:

export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512m"

OutOfMemoryError

查看更多
登录 后发表回答