是5287 AS3中的变量或$ P $栈限制pdefined? [英] Is the stack limit of 5287 in AS3 variable or predefined?

查看:115
本文介绍了是5287 AS3中的变量或$ P $栈限制pdefined?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跑了一个测试刚才:

function overflow(stack:int = 0):void
{
    if(stack < 5290)
    {
        trace(stack);
        overflow(stack + 1);
    }
}

overflow();

这始终之后 5287 通话抛出StackOverflow的错误。

This always throws a StackOverflow error after 5287 calls.

错误#1023:发生堆栈溢出

Error #1023: Stack overflow occurred.

时此限制值(根据机器的规格,环境等),或者是一台价值定义的地方吗?如果我在如果语句更改为小于5287,我没有得到这个错误。

Is this limit variable (depending on machine specs, environment, etc) or is that a flat value defined somewhere? If I change the if statement to less than 5287, I don't get the error.

推荐答案

显然,这是变量。由于所有的计算,你真的是位于堆栈(拆解报告codeS秀 pushbyte 的说明和其他东西,这与堆栈工作,非操作数算术),这价值仅报告的许多功能上下文如何被放入堆栈直到溢出。

Obviously it's variable. Since all the calculations you really do are located in stack (disassembly report codes show pushbyte instructions and other stuff that's working with stack, as non-operand arithmetics), this value only reports how many function contexts can be put into the stack until it overflows.

我决定运行一些测试递归阈值作为基于这是在巴里斯的引用此文评论。结果是pretty的尴尬。测试环境:FlashDevelop中3.3.4 RTM,Flash Player调试10.1.53.64,闪光编译方式:发布。 调试模式并没有改变数字cardinally,经检查发现了。

I have decided to run some tests for recursion thresholds as based on this article that was referenced in baris's comment. The results were pretty embarrassing. Test environment: FlashDevelop 3.3.4 RTM, Flash player debugger 10.1.53.64, flash compile mode: release. "Debug" mode didn't change numbers cardinally, checked that too.

Locals number     Iterations (static int)       Iterations (Math.random())   
0                 5306                          
1                 4864                          4856
2                 4850                          4471
3                 4474                          4149
4                 4153                          3870
5                 3871                          3868
6                 3869                          3621
7                 3620                          3404
8                 3403                          3217
9                 3210                          3214
10                3214                          3042
11                3042                          3045
10 mixed          3042     1 value was assigned Math.random() and 9 - static int
10 advancedRandom 2890     1 value was assigned a custom random with 1 parameter

请注意,所有这些值在十的后续执行之间的利润率变化。 静态INT和的Math.random()是什么分配给当地人wihin的递归调用的函数名称。然而,让我假设如下:

Note, all of these values vary within a margin of ten between subsequent executions. The "static int" and "Math.random()" are designations of what is assigned to locals wihin the recursively called function. This, however, leads me to assume the following:

  1. 在包括函数调用到递归函数添加功能方面
  2. 内存当地人连同它的类型​​分配,在超过800个字节的块,因为加入了当地的并不总是降低递归限制
  3. 添加多个呼叫到一个特定的功能不添加更多的内存功能方面
  4. 在该内存块是最有可能的16个字节长,因为这个值是2 ^ N,同比增加一个int或一些地方并不总是降低递归,这比8,作为一个原始值Number变量需要8个字节,是一个双precision浮点。
  5. 在假设#4是正确的,对于功能方面规模最大的价值似乎是172个字节,总堆栈大小为912632字节。这在很大程度上证实了我最初的假设是,堆栈大小实际上是1兆字节的Flash 10的F​​lash 11向我展示了一个高一点的数字,当我试图在调试器中打开测试SWF,但我并没有与它进行了广​​泛的测试。

这篇关于是5287 AS3中的变量或$ P $栈限制pdefined?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆