3

I'm trying to run my Spring Boot application in a machine with very limited resources (512M memory), so I need to configure JVM memory settings (Xmx, MaxPermSize etc) to limit consumption and avoid OOM crashes.

I run the app from the command line using Gradle:

gradle bootRun

but I haven't found a way to pass JVM args like -Xmx256m, -XX:MaxPermSize=128M etc. from the command line when starting the app. Any idea anyone?

2

2 Answers 2

2

You'd be better of building an executable JAR and then you can pass the java command whatever memory settings you want. Then you can just do:

java -jar -Xmx256m -XX:MaxPermSize=128M .... myApp.jar

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

1 Comment

new to the gradle thing, just needed to gradle build and then java -jar ... ./build/libs/nameOfJar.jar
0

You may sse this command in Linux/ Mac:

export _JAVA_OPTIONS="-Xms200m -Xmx800m" 

where values 200 and 400 can be changed as per your needs. Please note its _JAVA_OPTIONS

Then run your gradle command. e.g

gradle bootRun

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.