MATLAB Application Program Interface Reference | Help Desk |
mexMakeArrayPersistent
Make anmxArray
persist after the MEX-file completes
#include "mex.h" void mexMakeArrayPersistent(mxArray *array_ptr);array_ptr
Pointer to an mxArray
created by an mxCreate
routine.
mxArrays
allocated by mxCreate
routines are not persistent. MATLAB's memory management facility automatically frees nonpersistent mxArrays
when the MEX-file finishes.
Calling mexMakeArrayPersistent
marks an mxArray
as persistent. MATLAB does not automatically free persistent mxArrays
when the MEX-file finishes. In other words, the mxArray
persists through multiple invocations of the MEX-file.
If you do tag an mxArray
as persistent, make sure that the MEX-file does not accidentally recreate the same array each time the MEX-file gets called. That is, make sure that the mxArray
gets created the first time the MEX-file is called. Then, make sure that the mxArray
does not get created again on subsequent calls to the MEX-file.
mxArray
; the MEX-file is responsible for calling mxDestroyArray
to deallocate the heap space.
mexMakeArrayPersistent.c
in the mex
subdirectory of the examples
directory.
mexAtExit
, mexLock
, mexMakeMemoryPersistent
, and the mxCreate
functions.