Kemal Tunca
Kemal Tunca

Reputation: 281

Java Could not reserve enough space for object heap error

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

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.

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

Upvotes: 28

Views: 358422

Answers (9)

onClick
onClick

Reputation: 39

This is an old subject. But those using a stack, like Bitnami WildFly 13, should know that the stack installation has its own Java engine in \Bitnami\wildfly-13.0.0-1\java. On Windows, the installation takes the stack Java own engine for default configurations and it starts Java with option -client, not -server, even though there is/are other Java engines installed in the system. You need to modify standalone.conf.bat to specify explicitly your Java path and add -server option along with the desired memory allocation. Example:

set "JAVA_HOME=C:\Program Files\Java\jdk1.8.0_311”
set "JAVA_OPTS=-server -Xms2048M -Xmx4096M"
:JAVA_OPTS_SET
rem set "JAVA_HOME=C:\opt\jdk1.6.0_23\bin\java"

I hope this helps.

Upvotes: 0

Sealteam241
Sealteam241

Reputation: 91

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 settings for Windows 8 or

    control panelsystem and securitysystemadvanced system settings for 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_OPTIONS Variable Value: -Xmx512M

At least that is what worked for me.

Upvotes: 9

user3755563
user3755563

Reputation: 1907

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

Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M

Upvotes: 66

Mike
Mike

Reputation: 579

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

It's work for me!

Upvotes: 1

Jaxx0rr
Jaxx0rr

Reputation: 597

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

"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)

Upvotes: 3

user3573306
user3573306

Reputation: 91

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

Upvotes: 9

caleb
caleb

Reputation: 11

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

Upvotes: 1

rahulserver
rahulserver

Reputation: 11205

If you go thru this IBM 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 -Xmx2G and above.

Also if you go thru this SO 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.

Upvotes: 10

Lokesh
Lokesh

Reputation: 7940

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.

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

Upvotes: 2

Related Questions