how much memory does node allocate for null values in arrays
So in summary, node.js does not allocate memory for undefined values in an array. The crash I experienced must have been a glitch as no one else could reproduce it and installing the latest node.js version eliminated the problem for me as well.
EDIT : Sorry for inexact, Might not be applicable to JAVA..
Still might be helpful for someone who need it in other application.
An Array of reference is allocating x
therefore allocating arr[100000] will allocate 100 kb x 4b ~= 0.5Mb (approximating)
and YES, definitely, if you ain't gonna use all the Array,
you should consider a HashMap which is a datastructure just for that..
HashMap is best in having a large search span with relative small amount of items.
Either way, there are solutions to allocate a small array, and expand it as needed, if needed.