Tomcat 问题 - 无法保留足够的空间
我正在运行具有 256MB RAM 的服务器。我可以为 Java 分配的最大堆大小是 110MB。当我将这些参数添加到 JAVA_OPTS 时,我可以运行 java -version。问题是我无法使用这些参数运行 Tomcat。 Tomcat 运行的最大堆大小为 40MB。我不知道为什么我不能分配更多的内存?
当然我得到错误:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
I am running server with 256MB RAM. Maximum heap size I can allocate for Java is 110MB. When I add those param to JAVA_OPTS I can run java -version. Problem is that I can not run Tomcat with these parameters. Maximum heap size for Tomcat to run is 40MB. I do not know why I can not allocate more memory?
Of course I get error:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将
CATALINA_OPTS
设置为-Xmx110m
、JAVA_OPTS
。当然,我想你可以同时设置两者。Set
CATALINA_OPTS
to-Xmx110m
,JAVA_OPTS
. I suppose you could set both, to be sure.当您使用
-version
标志运行java
可执行文件时,Xmx
标志可能会被忽略。这取决于您如何传递版本标志。以下是我的 2GB RAM 机器上的结果:版本标志在 Xmx 之前传递,
考虑到 10G 超出了 32 位环境中内存的最大可寻址限制,这很奇怪。
Xmx之后传递的版本标志
更接近现实。
您可能想要使用第二种方法来验证 Java 实际上有多少连续内存可用,然后确定最大堆大小的最佳值。
The
Xmx
flag may be ignored when you run thejava
executable with the-version
flag. This depends on how you pass the version flag. The following are the results on my machine with 2GB RAM:Version flag passed before Xmx
which is weird considering that 10G is beyond the max addressable limit on memory in a 32-bit environment.
Version flag passed after Xmx
which is closer to reality.
You might want to verify how much contiguous memory is available to Java in reality, using the second approach, and then decide on an optimal value for the maximum heap size.
该错误消息表明您没有足够的可用 RAM,请尝试关闭其他应用程序,然后查看是否可以分配更大的堆。恐怕你可能需要更多的内存。
The error message suggests you do not have enough free RAM try closing other applications and seeing if you can allocate a larger heap then. You may need more RAM I am afraid.