Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

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

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?

question from:https://stackoverflow.com/questions/23072187/how-can-i-configure-the-heap-size-when-starting-a-spring-boot-application-with-e

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If starting the application with the spring-boot plugin:

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

Otherwise if running java -jar:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...