mxDestroyArray (C and Fortran)

Free dynamic memory allocated by MXCREATE* functions

C Syntax

#include "matrix.h"
void mxDestroyArray(mxArray *pm);

Fortran Syntax

subroutine mxDestroyArray(pm)
mwPointer pm



Pointer to the mxArray to free


mxDestroyArray deallocates the memory occupied by the specified mxArray. This includes:

  • Characteristics fields of the mxArray, such as size, (m and n), and type.

  • Associated data arrays, such as pr and pi for complex arrays, and ir and jc for sparse arrays.

  • Fields of structure arrays.

  • Cells of cell arrays.

Do not call mxDestroyArray on an mxArray:

  • you return in a left-side argument of a MEX-file.

  • returned by the mxGetField or mxGetFieldByNumber functions.

  • returned by the mxGetCell function.


See the following examples in matlabroot/extern/examples/refbook.

See the following examples in matlabroot/extern/examples/mex.

See the following examples in matlabroot/extern/examples/mx.

Was this topic helpful?