| MATLAB Application Program Interface | Search  Help Desk |
| mexMakeArrayPersistent | See Also |
Make an mxArray persist after the MEX-file completes
C Syntax
#include "mex.h" void mexMakeArrayPersistent(mxArray *array_ptr);
Arguments
array_ptrmxArray created by an mxCreate routine.
Description
By default,mxArrays allocated by mxCreate routines are not persistent. MATLAB's memory management facility automatically frees nonpersistent mxArrays when the MEX-file finishes. If you want the mxArray to persist through multiple invocations of the MEX-file, you must call mexMakeArrayPersistent.
Note: If you create a persistent mxArray, you are responsible for destroying it when the MEX-file is cleared. If you do not destroy the mxArray, MATLAB will leak memory. 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, mexMakeMemoryPersistent, and the mxCreate functions.