Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: Making C++ objects persistent between mex calls, and robust.
Posted:
Jun 8, 2010 10:41 AM
|
|
"Anthony Halley" wrote: > What exactly are you returning from init_mex()? Is that a pointer to a C++ class instance? Are you using "new" or "mxMalloc" to allocate the memory for that instance?
I haven't gotten round to implementing it myself, but I plan to return a pointer to a C++ class instance (cast as a uint64), with memory allocated using "new". MATLAB will call the myclass delete function when it clears the pointer, so the only time this wouldn't happen is if MATLAB crashed. However, in that case I'd hope that the OS' memory management system would free all the memory associated with that thread, including the memory allocated by "new".
|
|
|
|