This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

mexMakeArrayPersistent (C and Fortran)

Make array persist after MEX file completes

C Syntax

#include "mex.h"
void mexMakeArrayPersistent(mxArray *pm);

Fortran Syntax

#include "fintrf.h"
subroutine mexMakeArrayPersistent(pm)
mwPointer pm

Arguments

pm

Pointer to an mxArray created by an mxCreate* function

Description

By default, an mxArray allocated by an mxCreate* function is not persistent. The MATLAB® memory management facility automatically frees a nonpersistent mxArray when the MEX function finishes. If you want the mxArray to persist through multiple invocations of the MEX function, call the mexMakeArrayPersistent function.

Do not assign an array created with the mexMakeArrayPersistent function to the plhs output argument of a MEX file.

Note

If you create a persistent mxArray, you are responsible for destroying it using mxDestroyArray when the MEX file is cleared. If you do not destroy a persistent mxArray, MATLAB leaks 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, mxDestroyArray, mexLock, mexMakeMemoryPersistent, and the mxCreate* functions

Introduced before R2006a