Question

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?

Was it helpful?

Solution

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

OTHER TIPS

Have you tried disabling Firebug?

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top