Already read this Question but didn't come to an understandable answer.
I have an array new Array(105119296)
with a predefined size.
Then after the array was defined I started a loop to fill each index with a value.
This process normally runs in a webworker but crashes there as well as in the browser directly.
After 11184811 iterations in Chrome Mac 50.0.2661.102 (64-bit)
the execution crashes.
The script below reproduces the situation.
var len = 105119296;
var arr = new Array(len);
for(var i=0;i<len;i++){
var data = 0;// Math.round(Math.random()*10);
if(i>11184810){
console.log(i + '->' + data);
// At 11184811 Chrome dev tool crashes
}
arr[i] = data;
}
console.log('done');
My question in general is:
Is there a limit to the size an array can hold in javascript? And if not why is something like this not running properly in a webworker which is for my understanding for heavy tasks which would block the browsers view.