| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB Compiler |
| Contents | Index |
| Learn more about MATLAB Compiler |
| On this page… |
|---|
Generated C++ code provides consistent garbage collection via the object destructors and the MCR's internal memory manager optimizes to avoid heap fragmentation.
If memory constraints are still present on your system, try preallocating arrays in M. This will reduce the number of calls to the memory manager, and the degree to which the heap fragments.
When an mxArray is created in an application which uses the MCR, it is created in the managed memory space of the MCR.
Therefore, it is very important that you never create mxArrays (or call any other MathWorks function) before calling mclInitializeApplication.
It is safe to call mxDestroyArray when you no longer need a particular mxArray in your code, even when the input has been assigned to a persistent or global variable in MATLAB. MATLAB uses reference counting to ensure that when mxDestroyArray is called, if another reference to the underlying data still exists, the memory will not be freed. Even if the underlying memory is not freed, the mxArray passed to mxDestroyArray will no longer be valid.
For more information about mclInitializeApplication and mclTerminateApplication, see Calling a Shared Library.
For more information about mxArray, see Using mxArray.
![]() | Using C/C++ Shared Libraries on a Mac OS X System | Troubleshooting | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |