Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1083341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:25:20+00:00 2026-05-16T22:25:20+00:00

Recently I ran into a problem: Valid JSON when passed to the eval() function

  • 0

Recently I ran into a problem: Valid JSON when passed to the eval() function causes it to throw the error — “script stack space quota is exhausted”.

It is consistently reproducible, and through initial examination, it seems that this is a limitation on the number of object attributes/properties that can be defined (and not the size of the content).

Here’s the sample code:

function starttest()
{      
       var d = new Array(50000);
       var i = 0;

       for (i = 0; i < d.length; i++) {
            d[i] = new Object();
            d[i].a1 = 1;
            d[i].a2 = 2;
            d[i].a3 = i;
            d[i].a4 = i;
            d[i].a5 = i;
            d[i].a6 = i;
            d[i].a7 = i;
            d[i].a8 = i;
            d[i].a9 = i;
            d[i].a10 = i;
            d[i].a11 = i;
            d[i].a12 = i;
            d[i].a13 = i;
            d[i].a14 = i;
            d[i].a15 = i;
       }       



    var jsonString = JSON.stringify(d);  
    alert(jsonString.length);

    var obj = eval(jsonString);
    var count = 0;
    for( var i = 0; i< obj.length; i++) {

        for (var k in obj[i]) {
            if (obj[i].hasOwnProperty(k)) {
               ++count;
            }
        }
    }

    alert("Done! || Len: " + obj.length + " || " + "Attrib Count: " + count + " || " + typeof obj)
}

The funny thing is I can define many more objects than seen in the code snippet; the problem arises only when using the eval() function.

Any new insights into this would be greatly helpful. I know using eval() is not safe, and all… and I’m open to suggestions!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:25:21+00:00Added an answer on May 16, 2026 at 10:25 pm

    Yeah, this is a problem with Firefox’s JavaScript interpreter in general. It’s not just eval: if you put fifty thousand lines of:

    {a:1,b:2,c:3,d:4,e:5,f:6,g:7,h:8,i:9,j:10,a2:1,b2:2,c2:3,d2:4,e2:5,f2:6,g2:7,h2:8,i2:9,j2:10},
    

    in an array literal in a plain script file or <script> element, you get exactly the same error.

    It seems the complexity of a script block is limited by the compile-time JS_DEFAULT_SCRIPT_STACK_QUOTA. See 420869 and the related linked bugs.

    It’s relatively unlikely you should meet this in normal circumstances. Of course for the case of JSON you can use JSON.parse which, not being a full JavaScript interpreter, is not affected by this limitation. If you needed a non-valid-JSON JS literal parser that’s not affected, I guess you’d have to write it yourself… though it’d probably be annoyingly slow when you get to input this long.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's
I recently ran into a problem that I thought boost::lambda or boost::phoenix could help
I recently ran into a problem with a COM object that was using a
I'm writing a C parser using PLY, and recently ran into a problem. This
Here's a problem I ran into recently. I have attributes strings of the form
I recently ran into a problem where it seems I need a 'static abstract'
I recently ran into a problem caused by using fstream::eof(). I read the following
I recently ran into a issue where intermediate link betweeen a TCP server and
A co-worker recently ran into a situation where a query to look up security
I ran into an interesting behavior recently. It seems that if I override .equals()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.