Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: matlab/mex function doesn't free memory
Replies: 22   Last Post: Dec 10, 2012 1:49 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
James Tursa

Posts: 2,069
Registered: 8/5/09
Re: matlab/mex function doesn't free memory
Posted: Dec 4, 2012 2:11 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.