Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not reserve enough space for object heap to start JVM

Tags:

Just faced with strange issue. When i type

java -version 

i got

Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. 

.

java -Xms64m -Xmx64m -version 

This command works fine

java version "1.6.0_24" Java(TM) SE Runtime Environment (build 1.6.0_24-b07) Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode) 

If i change xms, xmx to 128m, i get error again.

Using top command and free -m i can see, that i got over 192 mb free, so why i still get this error ?

Mem:    262144k total,    64760k used,   197384k free,        0k buffers Swap:        0k total,        0k used,        0k free,        0k cached 

Thank you

like image 895
user12384512 Avatar asked Jul 10 '11 16:07

user12384512


People also ask

How do I fix Java heap space error?

OutOfMemoryError: Java heap space. 1) An easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options "-Xmx512M", this will immediately solve your OutOfMemoryError.

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.

What is maximum heap size for JVM?

The max JVM heap size limit has been removed since we moved to completely 64 bit releases. As such you are now limited by the OS and/or machine. The theoretical limit is 2^64 bytes, which is 16 exabytes (1 exabyte = 1024 petabytes, 1 petabyte = 1024 terabytes). However, most OS's can't handle that.


2 Answers

I had the same problem when using a 32 bit version of java in a 64 bit environment. When using 64 java in a 64 OS it was ok.

like image 93
Yamada Avatar answered Oct 20 '22 21:10

Yamada


It looks like the machine you're trying to run this on has only 256 MB memory.

Maybe the JVM tries to allocate a large, contiguous block of 64 MB memory. The 192 MB that you have free might be fragmented into smaller pieces, so that there is no contiguous block of 64 MB free to allocate.

Try starting your Java program with a smaller heap size, for example:

java -Xms16m ... 
like image 31
Jesper Avatar answered Oct 20 '22 22:10

Jesper