仪器时间档案器:<call stack =“”limit =“”达到=“”>是什么意思?我可以控制限制吗?</call>

时间:2014-09-17 09:02:34

标签: recursion profiling instruments stack-trace

Instruments screenshot showing <Call stack limit reached>

当我的程序执行深度递归算法时,Instruments中的Time Profiler会创建一个名为<Call stack limit reached>的新入口点函数。我想这意味着Time Profiler在采样时回溯当前堆栈时会有一些限制。

我能控​​制这个限制吗?如果是这样,怎么样?

修改

我已尝试Preferences->DTrace->Max Backtrace Depth设置,但似乎没有效果。

这是一个带有深度递归的短程序,可以达到定义的深度并花费一段时间:

#define RECURSION_DEPTH 200

void recurse( unsigned const depth )
{
    if( RECURSION_DEPTH == depth ) for( unsigned i = 0; i < 1000000000; ++i );
    else recurse( depth + 1 );
}

int main()
{
    recurse( 1 );
    return 0;
}

当我对此程序进行时间配置时,即使我将DTrace首选项设置为远大于200的数字,我仍然会看到<Call stack limit reached>现象。

1 个答案:

答案 0 :(得分:0)

您可以在DTrace部分中根据Instruments的首选项设置最大调用堆栈深度。初始调用堆栈限制为128。

enter image description here