Disable Dynamic Memory Allocation During Code Generation
To disable dynamic memory allocation using the MATLAB® Coder™ app:
To open the Generate dialog box, on the Generate Code page, click the Generate 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:
EnableDynamicMemoryAllocationproperty of the configuration object to
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.
- Minimize Dynamic Memory Allocation
- Provide Maximum Size for Variable-Size Arrays
- Set Dynamic Memory Allocation Threshold