Tomcat 问题 - 无法保留足够的空间

发布于 2024-11-13 14:33:51 字数 338 浏览 2 评论 0原文

我正在运行具有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吖咩 2024-11-20 14:33:51

CATALINA_OPTS 设置为 -Xmx110mJAVA_OPTS。当然,我想你可以同时设置两者。

Set CATALINA_OPTS to -Xmx110m, JAVA_OPTS. I suppose you could set both, to be sure.

悲凉≈ 2024-11-20 14:33:51

当您使用 -version 标志运行 java 可执行文件时,Xmx 标志可能会被忽略。这取决于您如何传递版本标志。以下是我的 2GB RAM 机器上的结果:

版本标志在 Xmx 之前传递

C:\Users\Reynolds>java -version -Xmx10240M
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)

考虑到 10G 超出了 32 位环境中内存的最大可寻址限制,这很奇怪。

Xmx之后传递的版本标志

C:\Users\Reynolds>java -Xmx10240M -version
Invalid maximum heap size: -Xmx10240M
The specified size exceeds the maximum representable size.
Could not create the Java virtual machine.

C:\Users\Reynolds>java -Xmx1524M -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine. 

更接近现实。

您可能想要使用第二种方法来验证 Java 实际上有多少连续内存可用,然后确定最大堆大小的最佳值。

The Xmx flag may be ignored when you run the java 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

C:\Users\Reynolds>java -version -Xmx10240M
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)

which is weird considering that 10G is beyond the max addressable limit on memory in a 32-bit environment.

Version flag passed after Xmx

C:\Users\Reynolds>java -Xmx10240M -version
Invalid maximum heap size: -Xmx10240M
The specified size exceeds the maximum representable size.
Could not create the Java virtual machine.

C:\Users\Reynolds>java -Xmx1524M -version
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine. 

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.

断爱 2024-11-20 14:33:51

该错误消息表明您没有足够的可用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文