I have a Java program which creates 4 empty byte arrays of MAX_INTEGER - 2
length and then halts on an infinite while
loop in the main method.
I have set my Windows Java settings to include params -Xms12g -Xms12g
(I have 16gb RAM).
When running the program in Netbeans IDE with the same params set for the VM, the program executes and I can see in Task Manager that ~8g RAM is being used which is about what I'd expect.
I have compiled the program into a standalone .jar file so that I can run it outside from Powershell but when attempting to run the line:
java -jar prog.jar -Xms12g -Xmx12g
I am being told I am exceeding the heap space somehow, but I've just seen this not to be the case through an IDE:
-XX:MaxPermSize=12g
seems to make no difference either, and the IDE's VM doesn't require this param.
What am I missing here?
-
Entire sourcecode for completeness:
package prog;
public class Prog
{
public static final byte[] arr1 = new byte[Integer.MAX_VALUE - 2];
public static final byte[] arr2 = new byte[Integer.MAX_VALUE - 2];
public static final byte[] arr3 = new byte[Integer.MAX_VALUE - 2];
public static final byte[] arr4 = new byte[Integer.MAX_VALUE - 2];
public static void main(String[] args)
{
while(true);
}
}