Main Content

Enable dynamic memory allocation for fixed-sized arrays

R2026b

Dynamic memory allocation for fixed-size arrays

Since R2023a

Description

App Configuration Pane: Memory

Configuration Objects: coder.MexCodeConfig | coder.CodeConfig | coder.EmbeddedCodeConfig

Control use of dynamic memory allocation for fixed-size arrays. By default, dynamic memory allocation is disabled for fixed-size arrays.

Enabling Dynamic memory allocation for fixed-size arrays allocates memory on the heap for fixed-size arrays whose size (in bytes) is greater than or equal to Dynamic memory allocation threshold.

If your code passes a structure that contains a fixed-size array to an external C/C++ function by using coder.ceval or a Code Replacement Library (CRL), enabling this parameter can change the generated structure type definition. Fixed-size array fields that exceed the dynamic memory allocation threshold change from statically allocated C/C++ arrays to specialized array types (emxArray in C code or coder::array in C++ code). You must update your custom C/C++ function signatures to accept the updated structure type.

This parameter is not supported for GPU Coder™.

Dependencies

To enable this parameter, select the Enable dynamic memory allocation check box.

Settings

Off

This value is the default value.

The code generator statically allocates memory for fixed-size arrays on the stack.

On

The code generator allocates memory dynamically on the heap for fixed-size arrays whose size (in bytes) is greater than or equal to the Dynamic memory allocation threshold.

Programmatic Use

Property: DynamicMemoryAllocationForFixedSizeArrays
Values: false | true
Default: false

Version History

Introduced in R2023a