Using the C++ Math Library    

Memory Management

The MATLAB C++ Math Library manages memory efficiently by allocating space for new arrays and then freeing the space when the memory is no longer in use. The library, like many C++ components, makes extensive use of temporary variables, many of which are dynamically allocated. The resulting number of allocations and deallocations is too large for the operating system's default memory management to handle with acceptable performance.

To handle this large number of allocations and frees, the library implements its own memory management system that replaces the operating system's default memory management scheme. The MATLAB C++ Math Library avoids an excessive number of calls to malloc() and free() by maintaining a memory pool of its own. This pool grows to accommodate the memory needs of your program.


 Exception Handling in the MATLAB C++ Math Library Setting Up Your Own Memory Management Routines