Main Content

Reduce Memory Usage for Signals

The configuration parameter Signal storage reuse reduces the memory requirements of your real-time program by enabling parameters that reuse the memory allocated for signals with an auto storage class. These parameters are the following:

  • Enable local block outputs

  • Reuse local block outputs

  • Reuse global block outputs

  • Optimize global data access

When the Enable local block outputs parameter is on, where possible the code generator declares block outputs as local variables instead of global variables. Replacing global variables with local variables improves execution speed and reduces RAM/ROM consumption. Creating more local variables can increase stack usage. Some of the global variables that the code generator can localize include:

  • Global signals that cross subsystem boundaries

  • Global signals across Simulink and Stateflow domains

  • Unused global state variables

  • Redundant local Data Store Memory block signals

When the Reuse local block outputs parameter is on, wherever possible the code generator reuses local (function) variables for block outputs. When you select Reuse global block outputs, the code generator reuses global (function) variables wherever possible.

The Optimize global data access parameter has these settings:

  • None

  • Use global to hold temporary results

  • Minimize global data access

When you select None, the code generator uses the default optimizations. The setting Use global to hold temporary results maximizes the use of global variables. The setting Minimize global data access minimizes the use of global variables by using local variables to hold intermediate values.

Clearing Signal storage reuse makes all block outputs global and unique, which often significantly increases RAM and ROM usage.

The code generator does not localize global variables for MATLAB system objects or AUTOSAR.

Related Topics