unable to set xmx beyond 4gb on system having 8gb RAM

Arun picture Arun · Apr 11, 2012 · Viewed 17.4k times · Source

I need to set

ANT_OPTS=-Xms1024m -Xmx6144m -XX:PermSize=1024m -XX:MaxPermSize=1024m

JAVA_OPTS=-Xms1024m -Xmx6144m -XX:PermSize=1024m -XX:MaxPermSize=1024m

I have a system with 8gb(recently upgraded from 4 gb)

But once i set the ant opts to above said value I am not able to run any of my ant targets and I get the following error

[ERROR] Argument error: -Xmx6144m
[ERROR] Specified maximum heap size (6144 MB) is larger than the address space on this platform (4 GB).
[WARN ] -XX:PermSize=1024m is not a valid VM option. Ignoring
[WARN ] -XX:MaxPermSize=1024m is not a valid VM option. Ignoring
Could not create the Java virtual machine.

This indicates the Java that I have on my system

java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Oracle JRockit(R) (build R28.1.0-123-138454-1.6.0_20-20101014-1351-windows-x86_64, compiled mode)

and I am running a Windows 7 on Intel Core 2 Duo 3Ghz processor and 8GB RAM.

PS: I did Google for the error and it was one of my first such occurrences where I did not get any links pointing to the specific solution.

Answer

Andrew T Finnell picture Andrew T Finnell · Apr 13, 2012

As discussed in the comments:

It would seem that your ANT installation is using a 32-bit JVM. While a 64-bi JVM is in your PATH ANT doesn't obey the JVM in your PATH, it first looks at JAVA_HOME. You can verify this by running $JAVA_HOME/bin/java -version.

You can update your environment to set JAVA_HOME to the 64-bit version or change the ANT script to always use a specific version of Java.