Java 无法为对象堆错误保留足够的空间

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

Java Could not reserve enough space for object heap error

javajvmminecraft

提问by Kemal Tunca

I have Java7 running on 32-bit Windows and 4 GB RAM, but:

我在 32 位 Windows 和 4 GB RAM 上运行 Java7,但是:

java -Xmx4G -Xms4G -jar Minecraft.jar 
java -Xmx3G -Xms3G -jar Minecraft.jar 
java -Xmx2G -Xms2G -jar Minecraft.jar

...still does not work. Error:

……还是不行。错误:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

VM 初始化期间发生错误
无法为对象堆保留足够的空间
错误:无法创建 Java 虚拟机。
错误:发生了致命异常。程序将会退出。

java -Xmx1G -Xms1G -jar Minecraft.jaris working. Why?

java -Xmx1G -Xms1G -jar Minecraft.jar正在工作。为什么?

回答by Lokesh

4gb RAM doesn't mean you can use it all for java process. Lots of RAM is needed for system processes. Dont go above 2GB or it will be trouble some.

4GB RAM 并不意味着您可以将其全部用于 Java 进程。系统进程需要大量 RAM。不要超过2GB,否则会很麻烦。

Before starting jvm just check how much RAM is available and then set memory accordingly.

在启动 jvm 之前,只需检查有多少 RAM 可用,然后相应地设置内存。

回答by rahulserver

If you go thru thisIBM link on java, it says that on 32 bit windows the recommended heap size is 1.5 GB and the Maximum heap size is 1.8 GB. So your jvm does not gets initialized for -Xmx2Gand above.

如果您通过Java 上的IBM 链接,它会说在 32 位 Windows 上推荐的堆大小为 1.5 GB,最大堆大小为 1.8 GB。所以你的 jvm 不会被初始化为-Xmx2G及以上。

Also if you go thru thisSO answer, clearly the DLL bindings are an issue for memory reservation changing which is no trivial task. Hence what may be recommended is that you go for 64-bit Windows and a 64-bit JVM. while it will chew up more RAM, you will have much more contiguous virtual address space.

此外,如果你通过这个SO 答案,显然 DLL 绑定是内存预留更改的一个问题,这不是一项微不足道的任务。因此,可能建议您使用 64 位 Windows 和 64 位 JVM。虽然它会占用更多 RAM,但您将拥有更多连续的虚拟地址空间。

回答by caleb

this is what worked for me (yes I was having the same problem) were is says something like java -Xmx3G -Xms3Gput java -Xmx1024Mso the run.bat should look like java -Xmx1024M -jar craftbukkit.jar -o false PAUSE

这对我有用(是的,我遇到了同样的问题)是说像java -Xmx3G -Xms3Gputjava -Xmx1024M这样的东西,所以 run.bat 应该看起来像 java -Xmx1024M -jar craftbukkit.jar -o false PAUSE

回答by user3573306

I had this problem. I solved it with downloading 64x of the Java. Here is the link: http://javadl.sun.com/webapps/download/AutoDL?BundleId=87443

我有这个问题。我通过下载 64x 的 Java 解决了这个问题。这是链接:http: //javadl.sun.com/webapps/download/AutoDL?BundleId=87443

回答by user3755563

Go to StartControl PanelSystemAdvanced system settingsadvanced(tab)Environment VariablesSystem VariablesNew:

转到StartControl PanelSystemAdvanced system settingsadvanced(tab)Environment VariablesSystem VariablesNew

Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M

回答by Jaxx0rr

to make sure it runs the 64 bit version of java have it like this:

为了确保它运行 64 位版本的 java,它是这样的:

"c:\Program Files\Java\jre7\bin\java.exe" -Xmx1536M -Xms1536M -XX:MaxPermSize=256M -jar forge-1.6.4-9.11.1.965-universal.jar

"c:\Program Files\Java\jre7\bin\java.exe" -Xmx1536M -Xms1536M -XX:MaxPermSize=256M -jar forge-1.6.4-9.11.1.965-universal.jar

take a look at what jre version you have installed just in case.. x64 should be in program files while x32 resides in Program Files (x86)

看看你安装了什么 jre 版本以防万一.. x64 应该在程序文件中,而 x32 驻留在程序文件中 (x86)

回答by user2284700

Double click Liferay CE Server -> add -XX:MaxHeapSize=512m to Memory args -> Start server! Enjoy...

双击 Liferay CE Server -> 将 -XX:MaxHeapSize=512m 添加到 Memory args -> 启动服务器!享受...

It's work for me!

这对我有用!

回答by Sealteam241

This was occuring for me and it is such an easy fix.

这对我来说发生了,这是一个很容易解决的问题。

  1. you have to make sure that you have the correct java for your system such as 32bit or 64bit.
  2. if you have installed the correct software and it still occurs than goto

    control panelsystemadvanced system settingsfor Windows 8 or

    control panelsystem and securitysystemadvanced system settingsfor Windows 10.

  3. you must goto the {advanced tab} and then click on {Environment Variables}.
  4. you will click on {New} under the <system variables>
  5. you will create a new variable. Variable name: _JAVA_OPTIONSVariable Value: -Xmx512M
  1. 您必须确保您的系统拥有正确的 java,例如 32 位或 64 位。
  2. 如果您安装了正确的软件并且它仍然出现而不是 goto

    control panelsystemadvanced system settings用于 Windows 8 或

    control panelsystem and securitysystemadvanced system settings用于 Windows 10。

  3. 您必须转到{高级选项卡},然后单击{环境变量}。
  4. 您将点击下方的{New} <system variables>
  5. 您将创建一个新变量。变量名称:_JAVA_OPTIONS变量值:-Xmx512M

At least that is what worked for me.

至少这对我有用。