0

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.

20
  • Did you check the vm-arguments of the runconfig of your Maven build? It may help to adjust the memory size here. For example, add -Xms1024M Commented Feb 6, 2020 at 7:58
  • Hi tgallei. Does this also have to be set in pom.xml as I tried the -Xmx parameter above ? Commented Feb 6, 2020 at 8:08
  • 1
    Java 7? Really? Are you using an outdated Eclipse and an outdated Maven too? Fix this first, everything else might be caused by that. Commented Feb 6, 2020 at 8:18
  • 1
    @FedericoklezCulloca Targeting an older Java 6 version does not require to use outdated tools. With Eclipse 2019-12 you can create Java 1.3 bytecode and with a Java 9 or higher JDK you can use the --release argument to create down to Java 6 bytecode without even having a Java 6 JDK. For security reasons, you should run your Java 6 and 7 application on a Java 8 VM. Commented Feb 6, 2020 at 8:49
  • 1
    @FedericoklezCulloca At the latest when there are no security updates for an outdated version anymore, upgrade. It's that simple. Sometimes you have to explain this to a decision maker without the technical knowledge. Most of us have faced this situation more than one time. In this case, not a single line of code has to be rewritten. On the other hand, outdated software means a high risk, which can cause high costs. Commented Feb 6, 2020 at 9:18

2 Answers 2

2

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

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

Sign up to request clarification or add additional context in comments.

Comments

1

@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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.