I had to write a depth-first tree iterator recently – at Xopus of course – and I wondered about the call stack size. Here is the test, and the results:
- Safari 2.04: 100
- Firefox 2.0.0.6: 1001
- Internet Explorer 7: 1789
- Opera 9.22: 3340
Safari surprises me, it’s just 10% of Firefox! Opera stands out quite clearly as well.

Safari 3.0.3: 100
Swift 0.2: 1000. That’s weird, Swift and Safari use both Webkit, Swift is just a Windows port (or am I wrong on that?).
IE6 gives an error for overflow, but then displays 893.
But, is 100 not just enough? I don’t see the need for so much subroutines in things I’ve worked on.
Gran Paradiso also has 1001.
Arjan, I think a 100 is too low. I’d reckon it’s quickly reached in complex systems (like Xopus).
This is WebKit bug 4045. There’s some concern of crashing the browser by overflowing the native call stack, but they’re working on it.
I posted a somewhat simpler stack depth experiment in my Chiron project SVN a while back.
Hey Kris, thanks for the update. Your experiment looks into recursion, which should give the same results but with a different error message.
The latest Safari3 beta also reports 100…
FYI Opera’s and IE’s call stack sizes are limited by the size of your ram which is why e.g. Arjan saw a limit of ~800. Firefox’ is fixed in the engine (but I don’t know if it’s a configuration or a compilation limit) and Safari’s is fixed at the compilation.
When you use a somewhat functional style, or a CPS style, in JS… a call stack limit of 100 is pretty much trivial to blow.
I recently just wrote this about getting around the call stack in Flash which has a limit of 256 levels. I’m not 100% sure this would be helpful, but I know Actionscript and JavaScript are pretty much the same.
Hi, a few points:
Firefox 1-2 and older Mozilla variants have had 1000 hardwired as the maximum call count (so the fencepost is 1001 — an off by one bug, but who’s counting?
. This limit was meant to defeat trivial denial-of-service attacks and save developers who make a runaway recursive function call by mistake from a browser crash.
But for several years we’ve used stack address sampling to enforce a 512K limit on stack depth from near top level event loop to deepest JS flow that samples in various opportunistic places in recursive or common functions. So we do not need the 1001 limit and I’ll file a bug to remove it (filed — thanks for prompting this).
For JS2/ES4 we are requiring proper tail calls. So CPS code will work without overflow.
HTH,
/be
Hey Brendan, thanks for the clarification. I think there was a brief discussion regarding call stacks at Kris Zyp’s talk at the Ajax Experience last month, don’t quite recall what number you mentioned back then. Anyway, sweet to see you’re removing the limit!
The bug on the 1001 limit has been fixed for Firefox 3.
/be
@ Mark As you can read in my comment, I have not that much experience with large applications. What is the minimum Xopus needs by the way?
@ Brendan Good to see that bugs like this are that quickly reported and solved after only reading a blog post
Arjan, for the best experience you’ll need a fast machine, lots of memory and IE 7. Say an ‘06 or ‘07 machine with plenty of memory.
I was going to test the Safari Beta for Windows for you but it crashed every time I tried to load this page…
Not that that should surprise anyone. Taking Safari to Windows is likely a headache that we web developers could have done without.
Go the Fox..
Yani
@Arjan Eising- We ran into the stack size issue with the Safari browser. All we are doing is taking a 2-dimensional array (5 columns, 401 rows) and separating each column into it’s own one-dimensional array. From there, we quick-sort, then unique the one-dimensional array. Safari comes back with a “Maximum call stack size exceeded” error in the JavaScript console. So clearly, it’s fairly easy to fill a 100 stack array.
Safari 3.0.4 on Leopard reports 500.
Hi there! New browser Firefox 3 Beta 1 reports: Maximum call stack size: 261503.
Pretty much. Is it true value?
Safari 3.0.5 (525.3) – pre 3.0.6 (connect.apple.com): 500
err, what do you do when you cant send email cause it says
“Maximum call stack size exceeded”
any clues? im using safari.
benj
Safari Webkit Build 34318 give back 161317!
On Leopard:
Glad to see Opera is not only the faster, but also the one with bigger JS call stack!
Opera 9.50 , Linux, maximum call stack 9999
IE7 gives an error for overflow, maximum call stack size exceeded.
It look likes things are changing, doing this test with Safari 3.1.2: Maximum call stack size: 34951
Strange results for IE7 when calling the debugger.
Chrome 1.0.514.43 Maximum call stack size: 21837 IE 7 Maximum call stack size: 1789 with error IE 7 Maximum call stack size: 1804 with error after calling debugger FireFox 3.0.5 Maximum call stack size: 3001
All on Windows XP SP3.
Had this error in Safari, and i saw some number comparison, so I thought i’d place the new Safari 4 (osx) score here..
Maximum call stack size: 43689
But still, i’m getting this error, most probably i’m doing something wrong though, continuing to search.