Loading a huge array in Internet Explorer 11 causes a stack overflow

I have a (generated) page with a very large jagged array. It is not initialized in IE11; I get SCRIPT28: Out of stack space and SCRIPT2343: Qaru at line: 1 . I have reduced the problematic page to a minimum with random data, and it looks like this:

 <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 actual file is ~ 500k lines, repeating the initialization of the array approximately ~ 14k times. The actual file is available here: ie11_stack_overflow_problem.zip

It will only crash when the initialization of the array is large enough. I have a triad of all kinds of variations, including including it in a function to give it its own volume, but to no avail. It works in all other browsers I tested, including IE8 on XP. My configuration is Win7 with IE 11.0.9600.17107 (fully updated).

Can anyone understand why this is happening?

+7
javascript arrays internet-explorer stack-overflow
source share
1 answer

This file is terrible and is the death kiss of both Visual Studio and Notepad ++ ... and indeed IE11. You blew up the translator.

I got this to work 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 as a JSON string and parse it.

+4
source share

All Articles