Minimum Stack Usage
Total size of local variables in function taking nested scopes into account 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 an optimistic estimate of the stack usage by a function. Unlike
the metric Maximum Stack Usage
, this metric
takes nested scopes into account. For instance, if variables are defined in two mutually
exclusive branches of a conditional statement, the metric considers that the stack space
allocated to the variables in one branch can be reused in the other branch.
The metric is the sum of these sizes in bytes:
Maximum value from the stack usages of the function callees. The computation uses the minimum stack usage of each callee.
For instance, in this example, the minimum stack usage of
func
is the same as the minimum 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 least 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:
MIN_STACK |
HIS Metric: No |