Make memory allocated by MATLAB persist after MEX function completes
#include "mex.h" void mexMakeMemoryPersistent(void *ptr);
#include "fintrf.h" subroutine mexMakeMemoryPersistent(ptr) mwPointer ptr
By default, memory allocated by MATLAB® is nonpersistent,
so it is freed automatically when the MEX function finishes. If you
want the memory to persist, call
If you create persistent memory, you are responsible for freeing it when the MEX
function is cleared. If you do not free the memory, MATLAB leaks memory. To free memory, use
mexAtExit to see how to register a function that gets
called when the MEX function is cleared. See
mexLock to see how
to lock your MEX function so that it is never cleared.
ptr— Pointer to memory
Pointer to the beginning of memory allocated by one of the MATLAB memory allocation routines, specified as
* in C or
mwPointer in Fortran.