Enable dynamic memory allocation
Enable dynamic memory allocation for fixed- and variable-size arrays
Since R2023a
Description
App Configuration Pane: Memory
Configuration Objects: coder.MexCodeConfig | coder.CodeConfig | coder.EmbeddedCodeConfig
The Enable dynamic memory allocation parameter specifies whether the code generator dynamically allocates memory for fixed- and variable-sized arrays. By default, the code generator:
Dynamically allocates memory for unbounded variable-size arrays.
Dynamically allocates memory for bounded variable-size arrays whose maximum size is greater than the Dynamic memory allocation threshold.
Statically allocates memory for bounded variable-size arrays whose maximum size is less than the Dynamic memory allocation threshold.
Statically allocates memory for fixed-size arrays.
If you disable dynamic memory allocation and your MATLAB® code uses unbounded variable-size data, code generation fails. In addition, if you disable dynamic memory allocation, all data is allocated statically on the stack. For large data structures, this might result in stack overflow.
However, dynamic memory allocation is an expensive operation. The relative performance cost can be high for small, bounded data sets. If the MATLAB code uses only small bounded variable-size data sets or small fixed-data data sets, disable dynamic memory allocation.
Dependencies
Selecting this parameter enables the parameters Enable dynamic memory allocation for fixed-sized arrays and Dynamic memory allocation threshold.
Settings
- On
This value is the default value.
The code generator allocates memory dynamically on the heap for variable-size arrays whose size (in bytes) is greater than or equal to the Dynamic memory allocation threshold.
- Off
The code generator statically allocates memory on the stack for variable-size arrays.
Programmatic Use
Property:
EnableDynamicMemoryAllocation |
Values: true |
false |
Default: true
|
Version History
Introduced in R2023a