In my HTML5/CSS3/JavaScript application I create instances of the main classes of the game. For example:
function initialize (iconsParamArray) {
for (var i = 0; i < iconsParamArray.length; i++) {
this._iconsArray[i] = new Icon(iconsParamArray[i]);
}
}
The length of the iconsParamArray can be more than one hundred. And sometimes in the middle of this process Safari unexpectedly closes. If I perform browser cache clearing in Safari settings panel, Safari works normally in around 70% of cases. It looks like GC can't collect all garbage from the memory in time. So memory amount exceeded the limit and browser closes.
Has anyone run into the same problem? How can I avoid this unexpected closings? Maybe I have to use setTimeout function for dividing initialization process on few parts?