Maximum Stack Usage
Total size of local variables in function plus maximum stack usage from callees
Description
Note
Support for computing code metrics in Code Prover will be removed in a future release. See Version History.
This metric is reported in a Code Prover analysis only.
This metric provides a conservative estimate of the stack usage by a function. The metric is the sum of these sizes in bytes:
Maximum value from the stack usages of the function callees. The computation uses the maximum stack usage of each callee.
For instance, in this example, the maximum stack usage of
func
is the same as the maximum stack usage offunc1
orfunc2
, whichever is greater.void func(void) { func1(); func2(); }
If the function calls are in different branches of a conditional statement, this metric considers the branch with the greatest stack usage.
The analysis does the stack size estimation later on when it has resolved which function calls actually occur. For instance, if a function call occurs in unreachable code, the stack size does not take the call into account. The analysis can also take into account calls through function pointers.
Your actual stack usage can be different from the metric value.
Some of the variables are stored in registers instead of on the stack.
Your compiler performs variable liveness analysis to enable certain memory optimizations. When estimating this metric, Polyspace® does not consider these optimizations.
Your compiler uses additional memory during a function call. For instance, compilers store the address to which the execution returns following the function call. When estimating this metric, Polyspace does not consider this hidden memory usage.
Compilers optimize temporary variables in different ways. This metric excludes temporary variables. Only the variables that are explicitly declared by the user are considered.
However, the metric provides a reasonable estimate of the stack usage.
To determine the sizes of basic types, the software uses your specifications for Target processor type (-target)
. The metric takes into account #pragma
pack
directives in your code.
Examples
Metric Information
Group: Function |
Acronym:
MAX_STACK |
HIS Metric: No |