|
|
Re: matlab/mex function doesn't free memory
Posted:
Dec 4, 2012 2:11 PM
|
|
"Xueming " <emilyhexueming@hotmail.com> wrote in message <k9l55g$j9c$1@newscl01ah.mathworks.com>...
> Currently I meet exactly the same problem. I wrote a function in C which returns mxArray* to Matlab, and this function is called in a shared library as well, and it will be called continuously. To free memory which occupied by return mxArray I wrote a function ( using mxDestroyArray), however, Matlab crashed, and seems it cannot find the location of returned mxArray. Is that becaues Matlab has it own garbage collection and after every call of function, it frees the memory occupied by returned mxArray? > Have you figured this issue out? I will appreciate a lot if you can give me any hint:)
In general, you should *not* be using mxDestroyArray on anything that is being returned to MATLAB. That will invalidate the data in the mxArray and cause MATLAB to crash.
James Tursa
|
|