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.inlineControl inlining of a specific function in generated code
coder.constFold expressions into constants in generated code
coder.cevalCall external C/C++ function


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