Script stack space exhausted firefox

我是研究僧i 提交于 2019-12-03 08:45:55

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!