MATLAB Application Program Interface
  Go to function:
    Search    Help Desk 
mexMakeArrayPersistent    Examples   See Also

Make an mxArray persist after the MEX-file completes

C Syntax

Arguments

array_ptr
  Pointer to an mxArray 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.

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.

Example

See mexmakearraypersistent.c in the mex subdirectory of the examples directory.

See Also

mexAtExit, mexLock, mexMakeMemoryPersistent, and the mxCreate functions.



[ Previous | Help Desk | Next ]