Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using a Direct Web Remoting (DWR) JavaScript library file and am getting an error only in Safari (desktop and iPad)

(我正在使用Direct Web Remoting(DWR)JavaScript库文件,并且仅在Safari(台式机和iPad)中出现错误)

It says

(它说)

Maximum call stack size exceeded.

(超出最大呼叫堆栈大小。)

What exactly does this error mean and does it stop processing completely?

(该错误的确切含义是什么,它会完全停止处理吗?)

Also any fix for Safari browser (Actually on the iPad Safari , it says

(也可以解决Safari浏览器的所有问题(实际上是在iPad Safari ,)

JS:execution exceeded timeout

(JS:执行超出超时)

which I am assuming is the same call stack issue)

(我假设是相同的调用堆栈问题))

  ask by testndtv translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
522 views
Welcome To Ask or Share your Answers For Others

1 Answer

It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you hit the call stack limit.

(这意味着在代码的某处,您正在调用一个函数,该函数又调用另一个函数,依此类推,直到达到调用堆栈限制。)

This is almost always because of a recursive function with a base case that isn't being met.

(这几乎总是因为没有满足基本情况的递归函数。)

Viewing the stack (查看堆栈)

Consider this code...

(考虑这段代码...)

(function a() {
    a();
})();

Here is the stack after a handful of calls...

(这是经过几次调用后的堆栈...)

网页检查器

As you can see, the call stack grows until it hits a limit: the browser hardcoded stack size or memory exhaustion.

(如您所见,调用堆栈会不断增长,直到达到极限:浏览器采用硬编码的堆栈大小或内存耗尽。)

In order to fix it, ensure that your recursive function has a base case which is able to be met...

(为了对其进行修复,请确保您的递归函数具有可以满足的基本情况。)

(function a(x) {
    // The following condition 
    // is the base case.
    if ( ! x) {
        return;
    }
    a(--x);
})(10);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...