运行 java -version 时“无法为对象堆保留足够的空间”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14926989/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 17:53:13  来源:igfitidea点击:

'Could not reserve enough space for object heap' when running java -version

javamemorywindows-server-2008virtual-memory

提问by dwjohnston

I know this is a common question/problem. I'm wondering where to get started with it.

我知道这是一个常见的问题。我想知道从哪里开始。

Running java on windows server 2008, we have 65GB memory, and it shows 25GB free. (Currently a couple of guys are running processes).

在 windows server 2008 上运行 java,我们有 65GB 内存,它显示 25GB 空闲。(目前有几个人正在运行进程)。

systeminfo | grep -i memory

systeminfo | grep -i memory

shows:

显示:

Total Physical Memory: 65, 536 MB
Available Physical Memory: 26,512MB
Virtual Memory: Max Size 69,630 MB
Virtual Memory: Available 299 MB
Virtual Memory: In Use: 69, 331 MB. 

Really just wondering how I go about solving this problem.

真的只是想知道我如何解决这个问题。

  • Where do I start?
  • What does it mean that more virtual memory is being used than physical memory, and is this why java won't start?
  • Does java want to use virtual memory rather than physical memory?
  • 我从哪里开始?
  • 使用的虚拟内存多于物理内存是什么意思,这就是 java 无法启动的原因吗?
  • java 是否要使用虚拟内存而不是物理内存?

java -version

java -version

gives me:

给我:

Error occured during initialization of VM could not reserve enough space for object heap

Error occured during initialization of VM could not reserve enough space for object heap

More specific questions:

更具体的问题:

  • Why doesn't the JVM want to use the free phsyical memory?
  • How much memory does a java command (like java -version) want to use if you don't specify Xms parameters?
  • Would simply assigning more virtual memory be a good solution to the problem?
  • 为什么JVM不想使用空闲的物理内存?
  • java -version如果不指定 Xms 参数,java 命令(如)要使用多少内存?
  • 简单地分配更多的虚拟内存是解决问题的好方法吗?

采纳答案by QuantumMechanic

As I discovered when I had a similar problem (though with a lot less memory on the system -- see Cannot run a 64-bit JVM in 64-bit Windows 7 with a large heap size), on Windows the JVM will try to allocate a contiguousblock of memory.

正如我在遇到类似问题时发现的那样(尽管系统上的内存少了很多——请参阅无法在具有大堆大小的 64 位 Windows 7 中运行 64 位 JVM),在 Windows 上,JVM 将尝试分配一个连续的内存块。

So my bet is that while you have enough totalmemory, you don't have enough contiguousmemory.

所以我敢打赌,虽然你有足够的内存,但你没有足够的连续内存。

回答by eldhose abraham

I got the same issue. From the analysis, we found that the machine have low swap space. Please increase the swap space and verify.

我遇到了同样的问题。通过分析,我们发现机器的swap空间不足。请增加交换空间并验证。

回答by NithinS

At least to see java version run java -Xmx64m -version this should show you the version if needed. Then you can try increasing Xmx and see at what value it fails

至少要查看 java 版本运行 java -Xmx64m -version 这应该会在需要时显示版本。然后您可以尝试增加 Xmx 并查看失败的值