How can I configure the heap size when starting a Spring Boot application with embedded Tomcat?

ghz 1years ago ⋅ 3385 views

Question

I am trying to deploy a Spring Boot powered web app to production. The app is built with Spring Boot 1.0.1 and has the default Tomcat 7 embedded as application server. I want to allocate larger memory to the app when start the app with java -jar myapp.jar command line.

Should I use JVM parameter such as -Xms -Xmx or use environment variable such as JAVA_OPTS? I have tried to look for the answer in documentation or google it, but I did not get an answer. Can anyone give some hints?


Answer

Just use whatever normal mechanism you would to set up the JVM. Documentation is available on the command line:

$ java -X
...
-Xms<size>        Set initial Java heap size
-Xmx<size>        Set maximum Java heap size
...