Loading huge array in Internet Explorer 11 cause stack overflow
I have a (generated) page with a very large jagged array. It does not initialize in IE11; I get SCRIPT28: Out of stack space
and SCRIPT2343: Stack overflow at line: 1
. I have reduced the problematic page to the bare minimum with randomized data, and this is what it looks like:
<html><body>
<div id="info">
Loading...
</div>
<script>
var d = [];
var i = 0;
d[i++] = [
"XHC_14",
0
];
d[i++] = [
"ZXS_26",
"UVT_27",
"QML_3149",
"MJO_3150",
15993327
];
d[i++] = [
"VKG_3156",
"ZEA_3157",
"KZG_3159",
"MNA_3162",
"AKX_3163",
"KLK_3164",
618601
];
// more array initialization ...
info.innerHTML = "<h1>Ready!</h1>"; // this will only show if the initialization succeeded
</script>
</body></html>
The real file is ~500k lines, repeating the array initialization around ~14k times. Real file available here: ie11_stack_overflow_problem.zip
It will only crash when the array initialization is large enough. I have triad all kinds of variation, including putting it inside a function to give it its own scope, to no avail. It works in all other browsers I tested, including IE8 on XP. My config is Win7 with IE 11.0.9600.17107 (fully updated).
Can anyone figure out why this is happening?
That file is horrendous and is the kiss of death to both Visual Studio and Notepad++... and indeed IE11. You've blown up the interpreter.
I got this to work by using
JSON.serialize(d)
in another browser, then pasting the output as a string into the source file.
Then:
var jsonStr = '[[blablabla...I go on foreeeeeever]]';
var d=JSON.parse(jsonStr);
Now it loads in IE11.
So the solution is to write your data structure out as a JSON string and to parse it.
链接地址: http://www.djcxy.com/p/79118.html