Details

By default, dynamic memory allocation is enabled for variable-size arrays whose size (in bytes) is greater than or equal to a configurable threshold. This behavior allows for finer control over stack memory usage. MATLAB Coder allocates memory for these variable-size arrays dynamically on the heap.

You must use dynamic memory allocation for unbounded variable-size data.

Select whether to enable dynamic memory allocation:


Tradeoffs to Consider

If you disable dynamic memory allocation, all data is allocated statically on the stack. For large data structures, this might result in stack overflow.

Dynamic memory allocation is an expensive operation; the performance cost may be too high for small data sets. If you use small variable-size data sets or data that does not change size at run time, disable dynamic memory allocation.