java 我们可以在一台机器上有多少个 JVM?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4678283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How many JVM we can have in one machine?
提问by xeranic
I have a class that run infinit (do nothing, just loop and sleep), called NeverReturn. I try to run it using following command in Windows XP 32bit:
我有一个运行 infinit 的类(什么都不做,只是循环和睡眠),称为 NeverReturn。我尝试在 Windows XP 32 位中使用以下命令运行它:
java -Xms1200M NeverReturn
java -Xms1200M 从不返回
I find with the command I can create only 4 java instance at same time. The 5th and next java command will failed to create jvm.
我发现使用该命令我只能同时创建 4 个 java 实例。第 5 个和下一个 java 命令将无法创建 jvm。
If I change the command to -Xms600M, I can create 8 java instance. The 9th will failed.
如果我将命令更改为 -Xms600M,我可以创建 8 个 java 实例。第 9 次将失败。
Could anyone explain that? I'm using sun jdk1.6 update 23 and jdk1.5 update 22.
有人能解释一下吗?我正在使用 sun jdk1.6 update 23 和 jdk1.5 update 22。
回答by templatetypedef
If you have four instances of the JVM each using 1200M of memory, that gives you 4800M of memory allocated.
如果您有四个 JVM 实例,每个实例使用 1200M 的内存,则分配给您 4800M 的内存。
If you have eight instances of the JVM each using up to 600M of memory, that gives you 4800M of memory as well.
如果您有 8 个 JVM 实例,每个实例使用多达 600M 的内存,那么您也可以获得 4800M 的内存。
If I had to guess, it looks like the problem is that you're trying to promise more memory to the JVM instances than exists on your system. Dropping the amount of memory you promise should have a corresponding increase in the number of instances you can run.
如果我不得不猜测,问题似乎在于您试图向 JVM 实例承诺比系统上存在的内存更多的内存。减少您承诺的内存量应该会相应增加您可以运行的实例数量。
回答by Ayusman
Simple answer: as many JVMs as you want; of course as long as your machine can provide the necessary resources (read memory).
简单的答案:任意数量的 JVM;当然只要你的机器能提供必要的资源(读内存)。
If you wanted to ask how many JDK/JREs you can use in a machine (different JDK/JRE versions); the answer is "there is no constraint".
如果要问一台机器可以使用多少个JDK/JRE(不同的JDK/JRE版本);答案是“没有限制”。
So you can have many JDKs as well, I am not sure of the windows installers though. You can always choose to use a dump instead.
所以你也可以有很多 JDK,不过我不确定 Windows 安装程序。您始终可以选择使用转储。
Hope this helps.
希望这可以帮助。
回答by Neil
For every instance of the virtual machine launched in this way, 600 MB of memory is dedicated to it, meaning if you only had 1 GB of memory, you could only successfully launch one instance of JVM if you allowed each instance to consume 600 MB of memory. By the sounds of it, you had roughly 4.6 GB of memory free at the time of running 8 instances of 600 MB each.
对于以这种方式启动的每个虚拟机实例,有 600 MB 的内存专用于它,这意味着如果您只有 1 GB 的内存,如果您允许每个实例消耗 600 MB 的内存,则您只能成功启动一个 JVM 实例记忆。听上去,在运行 8 个每个 600 MB 的实例时,您大约有 4.6 GB 的可用内存。