Given is a big (but not huge) array of strings (in numbers 1000-5000 single strings). I want to perform some calculations and other stuff on these strings. Because it always stopped working when dealing with that one big array, I rewrote my function to recursively fetch smaller chunks (currently 50 elements) - I did this using splice because I thought it would be a nice idea to reduce the size of the big array step by step.
After implementing the "chunk"-version, I'm now able to calculate up to about 2000 string-elements (above that my laptop is becoming extremely slow and crashing after a while).
The question: why is it still crashing, even though I'm not processing that huge array but just small chunks successively?
Thanks in advance.
var file = {some-array} // the array of lines
var portionSize = 50; // the size of the chunks
// this function is called recursively
function convertStart(i) {
var size = file.length;
chunk = file.splice(0,portionSize);
portionConvert(chunk,i);
}
// this function is used for calculating things with the strings
function portionConvert(chunk,istart) {
for(var i=0;i<portionSize;i++) {
// doing some string calculation with the smaller chunk here
}
istart += 1;
convertStart(istart); // recall the function with the next chunk
}