Main Content

Disable Dynamic Memory Allocation During Code Generation

To disable dynamic memory allocation using the MATLAB® Coder™ app:

  1. To open the Generate dialog box, on the Generate Code page, click the Generate arrow .

  2. Click More Settings.

  3. On the Memory tab, unselect the Enable dynamic memory allocation check box.

To disable dynamic memory allocation at the command line:

  1. In the MATLAB workspace, define the configuration object:

  2. Set the EnableDynamicMemoryAllocation property of the configuration object to false:

    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

More About