how much memory does node allocate for null values in arrays

arrays, javascript, memory, node.js, null

Solution

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.

Problem

Following up on this thread: Lots of null values in an array mean any harm? I did this with node.js: ``` arr=[] arr[1000]=1 arr[1000000000]=2 arr.sort() ``` And I got ``` FATAL ERROR: JS Allocation failed - process out of memory ``` So that leaves me with the question (I couldn't find it on Yahoogle) how much memory is actually allocated for a null entry in an array in node. I do not plan to use 1000000000 entries, not even close, but maybe it's still not worth allocating the memory... Who knows how I can check?

Original source