Tomcat内存消耗
我将在 Linux 上安装 Tomcat,JVM 堆大小为 2048m(2GB) 到 2304m(2GB+256MB) 通过在 catina.sh 文件
中设置 CATALINA_OPTS="-Xms2048m -Xmx2304m"
Linux 操作系统有 8GB RAM 所以我提出了一些观点,请帮忙解决这个问题
- Tomcat 应该直接从操作系统消耗 2GB 吗?
- 如果以上不是,那么应该花多少钱?
- 如果tomcat占用的内存小于2GB,那么操作系统为此tomcat分配的2GB内存仅用于此目的,或者某些应用程序可以使用此内存?
- 最后我们设置了最大和最小内存,这意味着操作系统为tomcat分配了所有这些内存量?
I am going to install Tomcat on linux with JVM Heap size as 2048m(2GB) to 2304m(2GB+256MB)
by setting CATALINA_OPTS="-Xms2048m -Xmx2304m"
in cataina.sh file
and the Linux OS have 8GB of the RAM
so i am making some points , please help with this
- Should tomcat consume directly 2GB from OS?
- If no to above ,then how much it should take?
- If memory is taken by the tomcat is less than 2GB then this 2GB memory allocated by os for this tomcat is only used for this only or some app can use this memory?
- and finally we are setting the this max and min memory , means OS allocates all that amount of the memory for tomcat?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JVM 将预先分配您为
-Xms
指定的任何内存。因此,它会在启动时请求并分配2GB内存。如果稍后需要更多内存(最多-Xmx
),JVM 会向操作系统请求更多内存。但是,您知道您需要这么多内存吗?内存消耗的主要驱动因素是您的应用程序,而不是 Tomcat。带有一些 servlet 或 JSP 的简单 Web 应用程序可以轻松地在不到 32MB 的堆中运行。您需要测量应用程序的性能/负载以确定最佳设置。
旁注 - 设置 JVM 参数的首选方法是使用
setenv.sh
中的JAVA_OPTS
设置,而不是 catalina.sh。The JVM will pre-allocate whatever memory you specify for
-Xms
. So, it will request and allocate 2GB of memory at startup. If it needs more memory later (up to-Xmx
), the JVM will request more memory from the OS.But, do you know you need this much memory? The main driver of memory consumption will be your application, not Tomcat. Simple webapps with a few servlets or JSPs can easily run in less than 32MB of heap. You need to measure your application for performance / load to determine the optimal setting.
A side note - the preferred method for setting JVM parameters is with the
JAVA_OPTS
setting insetenv.sh
, not catalina.sh.