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!

posted on Thursday, January 17, 2008 10:55 PM by scott

Comments

Friday, January 18, 2008 5:45 AM by dismal

# The Trivial Things You Can Learn When Stress Testi...

Bookmarked your post over at Blog Bookmarker.com!
Friday, January 18, 2008 6:58 AM by Josh Stodola

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

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

http://www.lomont.org/Math/Papers/2007/Excel2007/Excel2007Bug.pdf
Friday, January 18, 2008 7:12 AM by Jason Haley

# Interesting Finds: January 18, 2008

Friday, January 18, 2008 11:21 AM by scott

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

Wow - when that paper says it will analyze a bug - it isn't kidding!!
Saturday, January 19, 2008 6:47 AM by Christopher Steen

# Link Listing - January 18, 2008

Link Listing - January 18, 2008
Saturday, January 19, 2008 6:47 AM by Christopher Steen

# Link Listing - January 18, 2008

AJAX The Trivial Things You Can Learn When Stress Testing an AJAX Application [Via: scott ] Sharepoint...