Closed CsatiZoltan closed 7 years ago
@CsatiZoltan I don't know how other wrappers work. Check them if they fit your need.
mexplus wraps C++ classes with smart pointing and locking to prevent memory leak. Unless you manually do new
and delete
outside of mexplus API, you won't have a memory leak.
I think "wrapping without memory leak" refers more to the interaction of mex-files and C++ and that Matlab can unload them if it desires. I think this is a source of memory leaks, which is why it is non-trivial to safely wrap C++ classes to Matlab. Do C++ smart pointers completely prevent this kind of leaking?
@CsatiZoltan As to your first question, it doesn't look like either of these two projects is really active, and they don't look as mature as mexplus.
@patrikhuber Generally it is impossible to completely prevent memory leaking in C++, because anybody can do malloc
and not freeing in a mex file. But smart pointers in mexplus properly manage memory as long as correctly using the API. Even if a user does not release()
mxArray*
, Matlab has internal reference counting to prevent memory leaking. Locking mechanism manage unexpected unloading also.
@kyamagu , @patrikhuber Thank you for the explanations.
Cool, thanks @kyamagu!
I found two other C++/MATLAB class wrappers: this one and that one.
Thank you