Main Content

Dynamic memory allocation threshold in MATLAB functions


Specify a threshold for dynamic memory allocation. The code generator uses dynamic memory allocation for variable-size arrays whose size (in bytes) is greater than or equal to the threshold. This parameter applies to MATLAB® code in a MATLAB Function block, a Stateflow® chart, or a System object™ associated with a MATLAB System block. This parameter applies to the model during simulation and code generation. This parameter does not apply to:

  • Input or output signals

  • Parameters

  • Global variables

  • Discrete state properties of System objects associated with a MATLAB System block

Category: Simulation Target > Advanced parameters


Default: 65536

  • To specify the threshold, set this parameter to a positive integer.

  • To use dynamic memory allocation for all variable-size arrays, set this parameter to 0.


Dynamic memory allocation in MATLAB functions enables this parameter.

Command-Line Information

Parameter: MATLABDynamicMemAllocThreshold
Type: integer
Value: integer value
Default: 65536

Recommended Settings

DebuggingNo impact
TraceabilityNo impact
EfficiencyNo impact
Safety precautionNo recommendation

Related Topics