How can I estimate stack utilization?
The size of the user stack and interrupt stack is defined in the linker description via the variables USTACK and ISTACK respectively. A reasonable estimate can be obtained via the clang feature -fstack-usage
. A unit compiled with -fstack-usage
will generate an extra file with a .su extension that specifies the maximum amount of stack used per function in bytes, with an indicator that shows if the function frame size is:
Static: The measured size is reliable.
Dynamic: The measured size is not reliable.
Bounded: The stack is dynamic but the measured size is a reliable maximum.
The function "stack utilization", refers to the stack usage (number) per one invocation. For example, a recursive invocation may have a small number of bytes with a "static" indicator, even though it will create that stack for each of a million recursions, causing the program to crash. |