The Trivial Things You Can Learn When Stress Testing an AJAX Application

Internet Explorer has no problem creating an array of 65,536 elements.

var array = [];
for(var i = 0; i < 65535; i++)
{
    array.push(i);
}    
array.push(i);

alert(array.length);
// says 65536

However, IE does have a problem eval-ing an array of 65,536 elements.

var buffer = '[0';
for(var i = 0; i < 65535 / 15; i++)
{
    buffer +=
',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0';
}
buffer +=
']';

var array = eval(buffer);    
alert(array.length);
// would be 65536,
                     // if it got this far..

The code produces an out of memory error on the eval statement. The limit for eval appears to be 65,535 – a number that harkens back to the dark, dismal days of programming in a segmented memory architecture.

Of course, if you came here looking for the upper limits of evalyou might be doing something wrong!

Print | posted @ Friday, January 18, 2008 3:55 AM

Comments on this entry:

Gravatar # re: The Trivial Things You Can Learn When Stress Testing an AJAX Application
by Josh Stodola at 1/18/2008 2:58 PM

Ahhh yes, two to the power of sixteen minus one. Hear about the Excel bug related to this number?

www.lomont.org/.../Excel2007Bug.pdf
  
Gravatar # re: The Trivial Things You Can Learn When Stress Testing an AJAX Application
by scott at 1/18/2008 7:21 PM

Wow - when that paper says it will analyze a bug - it isn't kidding!!
  

Your comment:

Title:
Name:
Email:
Website:
 
Italic Underline Blockquote Hyperlink
 
 
Please add 3 and 7 and type the answer here: