Disable Dynamic Memory Allocation During Code Generation - MATLAB & Simulink (original) (raw)
Main Content
To disable dynamic memory allocation using the MATLAB® Coder™ app:
- To open the Generate dialog box, on theGenerate Code page, click theGenerate arrow
.
- Click More Settings.
- On the Memory tab, unselect the Enable dynamic memory allocation check box.
To disable dynamic memory allocation at the command line:
- In the MATLAB workspace, define the configuration object:
- Set the
EnableDynamicMemoryAllocation
property of the configuration object tofalse
:
cfg.EnableDynamicMemoryAllocation = false;
If a variable-size array in the MATLAB code does not have a maximum upper bound, disabling dynamic memory allocation leads to a code generation error. Therefore, you can identify variable-size arrays in your MATLAB code that do not have a maximum upper bound. These arrays are the arrays that are dynamically allocated in the generated code.
Related Examples
- Minimize Dynamic Memory Allocation
- Provide Maximum Size for Variable-Size Arrays
- Set Dynamic Memory Allocation Threshold