1

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?

Nick Melis
  • 313
  • 1
  • 2
  • 14
  • Doesn't these answers work for you? https://stackoverflow.com/questions/25079244/how-to-pass-jvm-options-from-bootrun/26141841 – Infinity Mar 18 '17 at 15:43
  • [ferto31](https://stackoverflow.com/users/12097702) posted an [Answer](https://stackoverflow.com/a/68687768) saying "This other post maybe can help you [Run application via gradlew with -Xmx and -Xms](https://stackoverflow.com/questions/44701947/run-application-via-gradlew-with-xmx-and-xms). or this one [https://gist.github.com/a-r-d/0880779347daedb30f3a72d4903ebe6d](https://gist.github.com/a-r-d/0880779347daedb30f3a72d4903ebe6d) or [How to pass JVM options from bootRun](https://stackoverflow.com/questions/25079244/how-to-pass-jvm-options-from-bootrun)." – Scratte Aug 18 '21 at 06:49

1 Answers1

0

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

Gregg
  • 33,473
  • 15
  • 101
  • 201