使用嵌入式Tomcat启动Spring Boot应用程序时如何配置堆大小? [英] How can I configure the heap size when starting a Spring Boot application with embedded Tomcat?
问题描述
我正在尝试将基于 Spring Boot 的Web应用程序部署到生产中.该应用程序是使用Spring Boot 1.0.1构建的,并嵌入了默认的Tomcat 7作为应用程序服务器.使用java -jar myapp.jar
命令行启动应用程序时,我想为应用程序分配更大的内存.
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.
我应该使用 JVM 参数(例如-Xms -Xmx
)还是使用环境变量(例如JAVA_OPTS
?我试图在文档或Google中寻找答案,但没有得到答案.任何人都可以给些提示吗?
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?
推荐答案
只需使用设置JVM的任何常规机制即可.可在命令行上找到文档:
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
...
这篇关于使用嵌入式Tomcat启动Spring Boot应用程序时如何配置堆大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!