Main Content

Memory Usage

Reduce RAM, ROM, and stack space used by generated C/C++ code

Determine how to modify your MATLAB® code so that the generated code uses less memory. When calling functions, control how data is passed by using the same variables for input and output. Passing by reference reduces the memory used in generated code. Control how memory is allocated by setting limits for stack space usage and by specifying when dynamic memory allocation is used. Minimize code size by disabling features that generate additional code, such as support for integer overflow.

For more information about how to optimize your code for specific conditions, see Optimization Strategies.


coder.areUnboundedVariableSizedArraysSupportedCheck if current configuration settings allow unbounded variable-size arrays (Since R2024a)
coder.cevalCall C/C++ function from generated code
coder.constFold expressions into constants in generated code
coder.inlineControl inlining of current function in generated code
coder.inlineCallInline called function in generated code (Since R2024a)
coder.nonInlineCallPrevent inlining of called function in generated code (Since R2024a)


coder.ConstantSpecification of constant value for code generation
coder.ExternalDependencyInterface to external code


Generated Code Optimizations

Conditional Statements

Function Calls


Numerical Edge Cases

Custom Code Integration