64 位操作系统上的 32 位 Java:JVM 数量有限制吗?
我有一台 Solaris sparc(64 位)服务器,具有 16 GB 内存。它上面运行着很多小型 Java 进程,但今天我在尝试启动新进程时收到“无法为对象堆保留足够的空间”错误。我很惊讶,因为服务器上还有超过 4GB 的可用空间。在其他一些进程关闭后,新进程能够成功启动;系统肯定已经达到了某种程度的上限。
在网上搜索解释后,我开始怀疑这是否与我使用 32 位 JVM(该服务器上的任何 java 进程都不需要太多内存)有关。
我相信默认的最大内存池是 64MB,并且我运行了接近 64 个这样的进程。因此,总而言之,这将是 4GB……正好在 32 位限制下。但我不明白为什么或如何这些过程会受到其他过程的影响。如果我是对的,那么为了运行更多这样的进程,我要么必须将最大堆调整为低于默认值,要么切换到使用 64 位 JVM(这可能意味着提高最大堆)高于这些进程的默认值)。我并不反对其中任何一个,但我不想浪费时间,而且现在这仍然是一次尝试。
谁能解释为什么它会这样工作?或者我完全错了?
如果我的解释是正确的,那么可能有关于此的文档:我非常想找到它。 (我正在运行 Sun 的 JDK 6 update 17,如果这很重要的话。)
编辑:我完全错了。下面的答案证实了我的直觉,即我没有理由不能运行尽可能多的 JVM。过了一会儿,我在同一台服务器上尝试运行非 java 进程时遇到错误:“fork:空间不足”。所以我遇到了一些其他限制,这些限制不是特定于 java 的。我必须弄清楚它是什么(不,它不是交换空间)。我很可能会转向服务器故障。
I have a Solaris sparc (64-bit) server, which has 16 GB of memory. There are a lot of small Java processes running on it, but today I got the "Could not reserve enough space for object heap" error when trying to launch a new one. I was surprised, since there was still more than 4GB free on the server. The new process was able to successfully launch after some of the other processes were shut down; the system had definitely hit a ceiling of some kind.
After searching the web for an explanation, I began to wonder if it was somehow related to the fact that I'm using the 32-bit JVM (none of the java processes on this server require very much memory).
I believe the default max memory pool is 64MB, and I was running close to 64 of these processes. So that would be 4GB all told ... right at the 32-bit limit. But I don't understand why or how any of these processes would be affected by the others. If I'm right, then in order to run more of these processes I'll either have to tune the max heap to be lower than the default, or else switch to using the 64-bit JVM (which may mean raising the max heap to be higher than the default for these processes). I'm not opposed to either of these, but I don't want to waste time and it's still a shot in the dark right now.
Can anyone explain why it might work this way? Or am I completely mistaken?
If I am right about the explanation, then there is probably documentation on this: I'd very much like to find it. (I'm running Sun's JDK 6 update 17 if that matters.)
Edit: I was completely mistaken. The answers below confirmed my gut instinct that there's no reason why I shouldn't be able to run as many JVMs as I can hold. A little while later I got an error on the same server trying to run a non-java process: "fork: not enough space". So there's some other limit I'm encountering that is not java-specific. I'll have to figure out what it is (no, it's not swap space). Over to serverfault I go, most likely.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不可以。32 位限制是每个进程(至少在 64 位操作系统上)。但是 默认最大堆不固定为 64MB :
No. The 32bit limit is per process (at least on a 64bit OS). But the default maximum heap is not fixed at 64MB:
我怀疑记忆被碎片化了。另请检查查看/解决 Windows XP 内存碎片的工具确认内存碎片可能导致此类错误。
I suspect the memory is fragmented. Check also Tools to view/solve Windows XP memory fragmentation for a confirmation that memory fragmentation can cause such errors.