Posts

Showing posts from March, 2011

Stack-Overflow and Out-of-Memory in JavaScript

Just to get it out on the Interwebz - how contemporary browsers behave when hitting two of the limits of the script execution environment:

stack overflow

Sample:

function a() { return a() + 1; } a();


IE9: Error, message: 'Out of stack space'Firefox 4: InternalError, message: 'too much recursion'Safari 5: RangeError, message 'Maximum call stack size exceeded'Chrome 10: RangeError, message: 'Maximum call stack size exceeded', type: 'stack_overflow'Opera 11: Error, message: 'Maximum recursion depth exceeded'
out-of-memory

Sample:

var s = 'x'; while(true) { s = s + s; }


IE9: Error, message: 'Out of memory'Firefox 4: InternalError, message 'allocation size overflow'Safari 5: Error, message: 'Out of memory'Chrome 10: sad browser tab - not catchable(?)Opera 11: my box ground to a crawl for several minutes; I ended up killing the process
Note that this could also indicate that a maximum size for a particular string was rea…