Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: Could not reserve enough space for object heap

Tags:

java

I am trying to allocate 2 gigs of ram to a java application started from a bat file using this line of code:

 @echo off
    "%ProgramFiles(x86)%\Java\jre6\bin\java.exe" -Xmx2G -Xms1G -jar craftbukkit-1.2.5-R4.0.jar
    pause

When I attempt to run it like this, however, it spits out an error saying:

 Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Could not create teh Java virtual machine
    Press any key to continue . . .

I currently have 8 gig of ram in my computer and I know I am using a max of 3 gigs at all times(I let the computer sit for the most part just running this server file). I have 2x4gig sticks of ram so I know its not separated out, and I know that I have enough free ram to allocate so why would it not let me? I am able to allocate 1536M(1.5 gigs) and under, but if I jump to 2G's it gives me this error. Any help is appreciated

like image 306
Xander Luciano Avatar asked Jun 18 '12 05:06

Xander Luciano


People also ask

How do I fix Java heap space error?

OutOfMemoryError: Java heap space error occurs when it attempts to add more data into the heap space area, but there is not enough room for it. The solution to fix this problem is to increase the heap space(Default value maybe 128 MB).

What is the maximum heap size of 32-bit and 64-bit JVM?

Max Heap Size. The maximum theoretical heap limit for the 32-bit and 64-bit JVM is easy to determine by looking at the available memory space, 2^32 (4 GB) for 32-bit JVM and 2^64 (16 Exabytes) for 64-bit JVM. In practice, due to various constraints, the limit can be much lower and varies given the operating system.

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?

To fix the error "Could not reserve enough space for object heap", add the options "-Xmx<size>m" to set the maximum size for the object heap memory allocation. This must be set large enough to accommodate loading your application into memory, but smaller than your requested total memory allocation by 2GB.


1 Answers

You shall make sure that you are using 64 bit version of java - 32 bit version will be unable to allocate that much even on 64 bit windows

like image 200
Konstantin Pribluda Avatar answered Sep 28 '22 02:09

Konstantin Pribluda