Main Content

Memory Usage

Optimize use of RAM, ROM, and stack space by generated code

Control memory consumption by specifying whether the code generator defines variables locally or globally and how data passes to subsystem functions. Modify configuration settings to reduce the amount of memory for storing data.

The code generator reduces ROM consumption by combining control flow constructs, removing dead code paths and code for blocks that do not have an impact on computational results. You can further reduce ROM consumption by removing code that you might not need such as initialization code, the reset and disable functions, and defensive code.

Model Settings

expand all

Signal storage reuseReuse signal memory
Optimize global data accessOptimize global variable usage
Remove root level I/O zero initializationControl generation of initialization code for root-level inports and outports set to zero
Remove internal data zero initializationControl generation of Initialization code for internal work structures, such as block states and block outputs, to zero
Maximum stack size (bytes)Specify maximum stack size for local variables in model
Default parameter behaviorRepresent numeric block parameters in generated code
Inline invariant signalsTransform symbolic names of Invariant signals in generated code
Default for underspecified data typeData type to use when Simulink cannot infer the data type

Topics

Memory Usage Optimization Basics

Define Variables Locally or Globally

Reduce Code Size

Reduce Memory for Storing Data