28

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?

AndrewSmiley
  • 1,933
  • 20
  • 32
Kemal Tunca
  • 281
  • 1
  • 3
  • 3

9 Answers9

66

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

Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M
Lernkurve
  • 20,203
  • 28
  • 86
  • 118
user3755563
  • 1,807
  • 1
  • 15
  • 6
  • 2
    Nice way to avoid configuring so much tools. Thanks. I tried to configure the flag on the VM instance, but for sure i did it wrong. Using system variable is by far better and just one time. Thank you. – m3nda Apr 24 '15 at 07:49
  • 2
    This worked like a charm. I was building in IntelliJ and had to restart the program though – Linda Lawton - DaImTo May 03 '17 at 08:25
10

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.

Community
  • 1
  • 1
rahulserver
  • 10,411
  • 24
  • 90
  • 164
9

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

user3573306
  • 91
  • 1
  • 1
9

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.

Lernkurve
  • 20,203
  • 28
  • 86
  • 118
Sealteam241
  • 91
  • 1
  • 1
3

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)

Jaxx0rr
  • 507
  • 4
  • 7
2

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.

Lokesh
  • 7,810
  • 6
  • 48
  • 78
1

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

donfuxx
  • 11,277
  • 6
  • 44
  • 76
caleb
  • 11
  • 1
1

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

It's work for me!

Mike
  • 569
  • 4
  • 6
0

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.

onClick
  • 29
  • 4