Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@a-r-d
Created January 30, 2018 16:15
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save a-r-d/0880779347daedb30f3a72d4903ebe6d to your computer and use it in GitHub Desktop.
Save a-r-d/0880779347daedb30f3a72d4903ebe6d to your computer and use it in GitHub Desktop.
A million ways to change HEAP memory in Java

Xmx vs Xms

Remember, Xmx corresponds to max heap and Xms corresponds to starting heap. It can be an optimization to set these equal.

In Spring Boot build.gradle

bootRun {
      jvmArgs = ['-Xmx1g']
}

java app from command line

java -Xmx512m -Dspring.profiles.active=dev -jar app.jar

From maven

mvn spring-boot:run -Drun.jvmArguments="-Xmx512m" -Drun.profiles=dev

From ENV variable:

export JAVA_OPTS="-Xmx1024m -Xms256m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment