Search code examples
javaspring-bootjvmjvm-arguments

JAVA 8: how to pass -xms and -xmx JVM values in the command


I'm running a springboot app on Java 8 environment

The command I use to run my app is this:

spring-boot:run -Plocalmysql -Dmaven.test.skip=true -Dspring.profiles.active=localmysql

My purpose is to add JVM values specification to my command; so i was suggested to use this options syntax: "-Drun.jvmArguments=Xms512m -Xmx512m"

But while running it throws me this warning :

> Java HotSpot(TM) 64-Bit Server VM warning: ignoring option
> PermSize=512m; support was removed in 8.0

Is there any workaround or a solution to keep passing it in the command?


Solution

  • It is just a warning message about another JVM parameter -XX:PermSize which is not supported since Java 8, because Permanent Generation was replaced with Metaspace.

    If you're having issues with setting JVM options for the memory size, for Spring Boot 2 you should use spring-boot.run.jvmArguments parameter:

    mvn spring-boot:run -Plocalmysql -Dmaven.test.skip=true -Dspring.profiles.active=localmysql -Dspring-boot.run.jvmArguments="-Xms512m -Xmx1024m"
    

    Or you can set these parameters in the Maven plugin configuration part of pom.xml:

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <jvmArguments>
                -Xms512m
                -Xmx1024m
            </jvmArguments>
        </configuration>
    </plugin>