From one side I am afraid my question will downvote soon and close. On another hand I really couldn't find the correct answer. This question is very close to mine but the answer accepted is fae away to be true in my case.
Do Java arrays have a maximum size?
To exemplify, if I run
public static void main(String args[]) {
String[] sa = new String[Integer.MAX_VALUE - 100];
}
with my current Java 9, I will get:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at...
It must exist a good explanation instead of a Integer.MAX_VALUE - magic number but I just can't find it.
*** edited
C:\>java -Xms4G -Xmx4G one.ex5
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at one.ex5.main(ex5.java:5)