-2

I want to add JAVA_OPTS in Intellij for a Spring Boot project and I don't know where to add it. I go to Edit configuration and then should I add it at the Environment variables like here: enter image description here But I don't think that it is ok how I set it because if I set it with this values "JAVA_OPTS=-Xms1m -Xmx1m", the app started properly. And also how can I log the JAVA_OPTS? Thank you in advance!

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
elvis
  • 956
  • 9
  • 33
  • 56

1 Answers1

1

You just add these to the VM options in your run configuration. Select Modify options > Add VM Options and put in -Xms1m -Xmx1m. Do not add JAVA_OPTS=, just the arguments.

Christopher Schneider
  • 3,745
  • 2
  • 24
  • 38
  • Thank you! I already tried to add it there but it didn't work because I used JAVA_OPTS=. Anyway do you know how to set also the CPU? Should I add something here at the VM options? – elvis Apr 17 '23 at 17:04
  • 1
    Not sure what you're looking to do. There are a lot of variables to consider. See https://stackoverflow.com/q/33723373/3059385 – Christopher Schneider Apr 17 '23 at 17:50
  • I want to set this microservice to use that memory and 2 CPUs. And I'm using Java 11. is this ok? -Xms128m -Xmx256m -XX:ActiveProcessorCount=2 – elvis Apr 18 '23 at 11:00
  • I'm not familiar with that flag, so I'd recommend reading through that question. It appears it doesn't actually limit the use to 2 CPUs, so you'd need some other way to limit available processors to the JVM. There are various solutions described in the answers to that question. – Christopher Schneider Apr 18 '23 at 15:20