| MATLAB Application Program Interface | Search  Help Desk |
| mexMakeMemoryPersistent | See Also |
Make memory allocated by MATLAB's memory allocation routines (mxCalloc, mxMalloc, mxRealloc) persist after the MEX-file completes
C Syntax
#include "mex.h" void mexMakeMemoryPersistent(void *ptr);
Arguments
ptrDescription
By default, memory allocated by MATLAB is nonpersistent, so it is freed automatically when the MEX-file finishes. If you want the memory to persist, you must callmexMakeMemoryPersistent.
Note: If you create persistent memory, you are responsible for freeing it when the MEX-file is cleared. If you do not free the memory, MATLAB will leak memory. To free memory, use mxFree. See mexAtExit to see how to register a function that gets called when the MEX-file is cleared; see mexLock to see how to lock your MEX-file so that it is never cleared.
See Also
mexAtExit, mexLock, mexMakeArrayPersistent, mxCalloc, mxFree, mxMalloc, mxRealloc