Script stack space exhausted firefox

Go To StackoverFlow.com

3

I am working with a large XML response from a web service. When I try to get that using a URL, after some time it displays an error in Firebug that "script stack space quota is exhausted" How can i resolve that?

2009-06-16 08:35
by Andromeda


4

It sounds like there is some recursion going on when processing the xml, that is essentially causing a stack overflow (by any name).

Thoughts:

  • work with less data
  • if you are processing the data manually, try to use less recursion? perhaps manual tail-call or queue/stack based
  • consider json - then you can offload to the script host to rehydrate the object without any extra processing
2009-06-16 08:38
by Marc Gravell


1

Have you tried disabling Firebug?

2009-06-16 08:39
by Alsciende
this is a good idea, just to make sure the problem is in firefox itsel - annakata 2009-06-16 08:40
its with the firefox itsel - Andromeda 2009-06-16 08:49


1

As of Firefox 3, the available stack space has dropped from 4MB to ~= 640KB (I'm passing on word of mouth here).

Do you happen to be running FF3?

https://bugzilla.mozilla.org/show_bug.cgi?id=420874

2010-02-16 10:06
by Chris Hagan


1

I had a similar problem, maybe the same. This can happen if you try to parse a huge chunk of html with jQuery $(html).

In my tests this only happened on Firefox 3.6.16 on Windows. Firefox 4.0.1 on Ubuntu behaved much better. Probably nothing to do with the OS, just the script engine in 4.x is much better..

Solution: Instead of

var $divRoot = $(html);

I did

var $temp = $('<div style="display:none;">');  // .appendTo($('body'));  // (*)
$temp.html(html);  // using the client's html parsing
var $divRoot = $('> div', $temp);  // or .children() or whatever
// $temp.remove();  // (*)

(*) I remember that in some cases you need to add the temp node to the body, before jquery can apply any selectors. However, in this case it seemed to work just fine without that.

There was absolutely no difference on FF 4.x, but it did allow to avoid the stack space overflow error on FF 3.x.

2011-06-15 16:18
by donquixote
+1 thanks - your answer led me to the fix for me - John in MD 2011-11-01 18:46