I am trying to instantiate a huge ArrayList
List<Integer> list = new ArrayList<Integer>(Integer.MAX_VALUE);
Running it in eclipse I get:
java.lang.OutOfMemoryError: Requested array size exceeds VM limit
If I do:
List<Integer> list = new ArrayList<Integer>(Integer.MAX_VALUE - 2);
I get a different error:
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory failed; error='The paging file is too small for this operation to complete'
#
# there is insifficent memory for the Java Runtime Environment to continue.
I start the program with the following setting in the run configurations in eclipse:
-Xmx8G
So what is the problem here? Even if I increase to -Xmx16G
it still gives the same error
Update
I am bit confused, does the actual size of RAM matter here? Dont processes have access to unlimited virtual memory thanks to paging?