简体   繁体   中英

Maven build on Eclipse: java.lang.OutOfMemoryError: Java heap space

I know this has been asked multiple times before, but no solution worked so far in my case.

Situation: I'm trying to build a Maven project. The environment is JDK 1.7 on Eclipse.

Problem: Upon running a Maven build, I get the following error:

java.lang.OutOfMemoryError: Java heap space

What I've tried : In my pom.xml I tried from other StackOverFlow answers:

                        <fork>true</fork>
                        <meminitial>512m</meminitial>
                        <maxmem>1048m</maxmem>
                        <verbose>true</verbose>
                        <argLine>-Xmx1024m</argLine>

I also changed the memory settings in eclipse.ini

Any help will be greatly appreciated.

If you are trying this on a Linux machine, set MAVEN_OPTS as below and see.

export MAVEN_OPTS="-Xms1024m -Xmx4096m -XX:PermSize=1024m"

@tagellei gave the correct answer (in the comments section). Thanks @tagellei

Right-click on the project --> Run As --> Run Configurations --> Click the JRE Tab on the pop-up window --> Under VM arguments, type: -Xms512M -Xmx1024M

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM