Re: Is there memory leak in mex programming?



Sorry, I meant the mxArray is copied rather than its data.
If the data isn't copied in the a(:,i) = MyMexFun() case I
would be impressed though...

Steve Eddins <Steve.Eddins@xxxxxxxxxxxxx> wrote in message
<fiovh0$7sh$1@xxxxxxxxxxxxxxxxxx>...
Andrew wrote:
I'll add that Matlab seems to treat the output mxArrays
of
mex function as temporary variables. Say if you have a
function:

X = MyMexFun();

If you check the memory address stored in plhs[0] it
will
not be the same memory address as X. So X, or in your
case
a(:,i), gets a copy of plhs[0] and then plhs[0] is
destroyed.

The data in the array is not actually copied.

--
Steve Eddins
http://blogs.mathworks.com/steve

.