Your application might be constrained by limited memory. Controlling the maximum allowable size for the stack is one way to modify whether data is defined as local or global in the generated code. You can limit the use of stack space by specifying a positive integer value for the Maximum stack size (bytes) parameter, on the Optimization pane of the Configuration parameter dialog box. Specifying the maximum allowable stack size provides control over the number of local and global variables in the generated code. Specifically, lowering the maximum stack size might generate more variables into global structures. The number of local and global variables help determine the required amount of stack space for execution of the generated code.
The default setting for Maximum stack size (bytes) is
target. In this case, the value of the maximum stack
size is the smaller value of the following: the default value set by the
code generator (200,000 bytes) or the value of the TLC variable
MaxStackSize found in the system target file
To specify a smaller stack size for your application, select
Specify a value option of the Maximum
stack size (bytes) parameter and enter a positive integer
value. To specify a smaller stack size at the command line, use:
set_param(model_name, 'MaxStackSize', 65000);
For overall executable stack usage metrics, you might want to do a target-specific measurement, such as using runtime (empirical) analysis or static (code path) analysis with object code.
It is recommended that you use the Maximum stack size
(bytes) parameter to control stack space allocation instead
of modifying the TLC variable,
the system target file. However, a target author might want to set
the TLC variable,
MaxStackSize, for a target. To
in the system target file (
ert.tlc), as in the
%assign MaxStackSize = 4096
%assign statements in the
RTW code generation settings section of the system target
%assign statement is described in Target Language Compiler.