Java Invalid Maximum Heap Size for Windows Remote Desktop

javaout-of-memoryremote desktop

I am running a Java application on a windows server (32-bit, 12GB RAM) with the
-Xmx8g and I am getting an error saying

Invalid Maximum Heap Size.
The specified size exceeds the maximum representable size.

But the same application is running on my local machine (64-bit, win-7, 6GB RAM) with the same -Xmx8g command.

I dont have the option of changing the OS of the server. Is there any possible solution to this?

Best Answer

With 32-bit-windows the adress-space cannot be larger than 4GB. By default half of this is reserved for the OS, so the maximum memory available for the JVM is 2GB. Reserve some for stack and other native memory and the maximum heap-size will end up with about 1.5GB.

Using the /3G-switch for windows might increase that limit by 1GB (as it limits the OS-storage to 1GB), but that is all that is the maximum that's possible in a 32-bit OS (and with a 32-bit JVM in general).