Can I rely completely on the memory management of MATLAB to free up the memory in my C-MEX routine?
MATLAB frees up the memory automatically in C-MEX routines. Do I have to explicitly use the mxFree routine to free up the memory allocated? Is there any advantage of using mxFree over completely relying on the memory management of MATLAB? MATLAB documentation says:
It is a good programming practice to deallocate memory just as soon as you are through using it. Doing so generally makes the entire system run more efficiently.
If the memory management engine of MATLAB is going to free up the memory automatically, why is the use of mxFree more efficient?
Best Answer