SimonD
SimonD

Reputation: 638

Instruments Time Profiler: What does <Call stack limit reached> mean? Can I control the limit?

Instruments screenshot showing <Call stack limit reached>

When my program is executing a deeply recursive algorithm, the Time Profiler in Instruments creates what looks like a new entry point function called <Call stack limit reached>. I guess this means that Time Profiler has some limit when back-tracing the current stack when it samples.

Can I control this limit? If so, how?

Edit

I've tried the Preferences->DTrace->Max Backtrace Depth setting but it appears to have no effect.

Here is a short program with deep recursion that gets to the defined depth an spends a while there:

#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;
}

When I Time Profile this program, I continue to see the <Call stack limit reached> phenomenon even if I set the DTrace preference to a number much greater than 200.

Upvotes: 2

Views: 2344

Answers (1)

Swift Dev Journal
Swift Dev Journal

Reputation: 20088

You can set the maximum call stack depth from Instruments' preferences, in the DTrace section. The initial call stack limit is 128.

enter image description here

Upvotes: 1

Related Questions