简体   繁体   中英

Maven - increase memory for JVM

I have tried multiple ways to increase the given memory for the JVM.
The OS is: Ubuntu 18.04.03 LTS
To start the program I use the exec-maven-plugin . I start it with following command: mvn clean compile exec:java .

However I need more memory.
To check the given memory for the jvm I use: Runtime.getRuntime().maxMemory() . (Currently it's 32gb, 120gb are on the system)

To increase it I have tried multiple things.

  1. Using the surefire plugin:
<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.5</version>
        <configuration>
            <argLine>-Xmx102400m</argLine>
        </configuration>
</plugin>

System.out.println(Runtime.getRuntime().maxMemory()) still prints 32gb.

  1. set MAVEN_OPTS="-Xmx102400m"
  2. mvn clean install -DargLine="-Xmx102400m"
    (To be honest I don't even have an idea why this should work.)

I can't use intellij or eclipse to increase the jvm memory, since the program runs on a server.
I don't have any idea left and I can't find an other solution on the web.

这个参数应该可以解决问题: -Drun.jvmArguments="-Xmx512m -xms1024"

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