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.
Generated Code Optimizations
Optimize the execution speed or memory usage of generated code.
Allocate large variables on the heap when you have limited stack space.
To improve the performance of generated code, the code generator uses optimizations.
Make a control-flow variable constant to prevent code generation of unused branches.
Make the control-flow variable constant to prevent generation of code for unused branches.
Generate code that passes input arguments by reference.
Inlining eliminates the overhead of function calls but can produce larger C/C++ code and reduce code readability.
Specify the maximum stack space that the generated code can use.
Reduce execution time by replacing expression with constant in the generated code.
Numerical Edge Cases
Improve performance by suppressing generation of supporting code to handle integer overflow or nonfinites.
Custom Code Integration
Improve performance by integrating your own optimized code.
Choose the correct fast Fourier transform implementation for your workflow and target hardware.
Generate LAPACK calls for certain linear algebra functions. Specify LAPACK library to use.
Generate BLAS calls for certain low-level matrix operations. Specify BLAS library to use.
Generate FFTW library calls for fast Fourier transforms. Specify the FFTW library.