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 ]
Xueming

Posts: 4
Registered: 12/4/12
Re: matlab/mex function doesn't free memory
Posted: Dec 10, 2012 1:49 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"James Tursa" wrote in message <k9t4q4$ien$1@newscl01ah.mathworks.com>...
> "Xueming " <emilyhexueming@hotmail.com> wrote in message <k9sg64$2c9$1@newscl01ah.mathworks.com>...
> >
> > James,hank you very much for pointing out my misunderstanding of garbage collection mechanism, and my careless about pointer initialization. I found the memory management issues on Mathwork website, and gonna take a look very carefully.
> > Btw, I tried to put mexMakeArrayPersistent(mxCell_g);
> > following
> > mxSetCell(mxCell1,1,mxString);
> > mxCell_g=mxCell1;
> > but it did work. I was wondering since there is a cell in mxCell1, should I keep it from being destroyed as well?

>
> What do you mean "... but it did not work"? Can you show your current code and what errors/problems you are currently encountering? As far as mxCell1 being a cell, that makes no difference ... mexMakeArrayPersistent works regardless of the type of variable argument.
>
> James Tursa


Hi James,
my code was no big difference for the previous on, I just add mexMakeArrayPersistent(mxCell_g); and the code is like below:
{
...
mxCell1=mxCreateCellMatrix(1,2);
mxSetCell(mxCell1,0,mxCell);
mxSetCell(mxCell1,1,mxString);
mxCell_g=mxCell1;

mxCell_g=mxCell1;
mexMakeArrayPersistent(mxCell1);
return mxCell_g;
}

The result turned out as the same as without mexMakeArrayPersistent(mxCell1).

Emily



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.