I was making a large Map in Node.js v11.9.0 and it kept failing with \"FATAL ERROR: invalid table size Allocation failed - JavaScript heap out of memory\". My map\'s keys an
What's interesting is if you change your code to create two Map objects and insert into them simultaneously, they both crash at exactly the same point, 16.7:
var N = Math.pow(2, 26);
var m1 = new Map();
var m2 = new Map();
for (var i = 0; i < N; i++) {
m2.set(i, i + 1);
m1.set(i, i + 1);
if (i % 1e5 === 0) { console.log(m1.size / 1e6); }
}
There's something odd happening here when more than 224 entries are made in any given Map, not globally across all Map objects.
I think you've found a V8 bug that needs to be reported.