I am running the following code using the java -Xmx60g
command.
Each array should be around 8.5GB, for a total of 17GB. The machine has 64GB total, with 63GB "free." It prints DONE DECLARING RIVER HANDS 1
, indiciating that it finished declaring the first array.
But I get Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
during the declaration of the second array. I am confused, because my understanding is that the -Xmx60g
should allocate 60GB, while the arrays only use 17GB.
Thanks in advance for your help!
long NUM_RIVER_HANDS = 2428287420L;
int half_river = (int)(NUM_RIVER_HANDS/2);
byte[][] river_hands_1 = new byte[half_river][7];
System.out.println("DONE DECLARING RIVER HANDS 1");
byte[][] river_hands_2 = new byte[(int)(NUM_RIVER_HANDS - half_river)][7];
System.out.println("DONE DECLARING RIVER HANDS 2");