wood burning stoves*
The moose likes Java in General and the fly likes Using -Xmx option with java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Using -Xmx option with java" Watch "Using -Xmx option with java" New topic
Author

Using -Xmx option with java

sayali s kulkarni
Greenhorn

Joined: Nov 13, 2010
Posts: 4
I have 8GB memory and I am trying to allocate 4GB to one of the java processes as;
java -Xmx4000m testpck.testPrg
But this seems to give the following error:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

I have double checked my RAM size and it is 8GB with 16G swap space. What could I be possibly missing? Is there some other setting in jvm options I need to specify?

Thanks in advance for the help.

--sayali
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
It depends on the operating systems and the JVM you're using. Here are some hints: http://stackoverflow.com/questions/171205/java-maximum-memory-on-windows-xp
sayali s kulkarni
Greenhorn

Joined: Nov 13, 2010
Posts: 4
Thanks for the tip Lester.

My current OS is Linux (64-bit). When I tried searching a bit more on this, http://www.coderanch.com/t/504688/java/java/Mamimum-Value-which-allowed-XMX#2277538 references a similar issue but seems that some are able to 8GB on a 64-bit linux.

Could someone please let me know if there are any other specific JVM/system configs that I need to look for?

Thanks in advance once again,
--sayali
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18914
    
  40

sayali s kulkarni wrote:
Could someone please let me know if there are any other specific JVM/system configs that I need to look for?


The most obvious thing to check is... did you install the 64 bit Java ?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
sayali s kulkarni
Greenhorn

Joined: Nov 13, 2010
Posts: 4
Mine is 32-bit java.
$java -d64 -version
This Java instance does not support a 64-bit JVM.

Might this be the issue? If yes, the max memory that I can get with 32-bit version is just 2.5G even when my RAM is 8gig?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18914
    
  40

sayali s kulkarni wrote:
If yes, the max memory that I can get with 32-bit version is just 2.5G even when my RAM is 8gig?


How much memory available to the JVM depends on it works with the OS. With a 32 bit JVM, the theoretical maximum is 4 gig -- with most 32 bit JVMs, it is around 2 gig. You are actually lucky with 2.5 gig. I seen it as low as less than 1.5 gig.

Why don't you install a 64 bit JVM? This way, you can use a lot more memory -- well, until the GC starts to choke...

Henry
sayali s kulkarni
Greenhorn

Joined: Nov 13, 2010
Posts: 4
Thanks a lot for the tips Henry. Will try with a 64-bit JVM.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using -Xmx option with java