Main Content

Maximum stack size (bytes)

Specify maximum stack size for model

Model Configuration Pane: Code Generation / Optimization

Description

The Maximum stack size (bytes) parameter specifies the maximum stack size in bytes for your model.

Settings

Inherit from target (default) | <Specify a value>
Inherit from target

The Simulink® Coder™ software assigns the maximum stack size to the smaller value of the following:

  • The default value (200,000 bytes) set by the Simulink Coder software

  • Value of the TLC variable MaxStackSize in the system target file

<Specify a value>

Specify a positive integer value. Simulink Coder software assigns the maximum stack size to the specified value.

Note

If you specify a maximum stack size for a model, the estimated required stack size of a referenced model must be less than the specified maximum stack size of the parent model.

Tips

  • If you specify the maximum stack size to be zero, then the generated code implements all variables as global data.

  • If you specify the maximum stack to be inf, then the generated code contains the least number of global variables.

  • If your model contains a variable that is larger than 4096 bytes, the code generator implements it in global memory by default. You can increase the size of variables that the code generator places in local memory by changing the value of the TLC variable MaxStackVariableSize. You can change this value by typing the following command in MATLAB Command Window:
    set_param(modelName,'TLCOptions','-aMaxStackVariableSize=N')

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo impact

Programmatic Use

Parameter: MaxStackSize
Type: int
Value: valid value
Default: Inherit from target

Version History

Introduced in R2010a