kyamagu / mexplus

C++ Matlab MEX development kit.
Other
99 stars 49 forks source link

How does this program compare with others? #22

Closed CsatiZoltan closed 7 years ago

CsatiZoltan commented 7 years ago

I found two other C++/MATLAB class wrappers: this one and that one.

Thank you

kyamagu commented 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.

patrikhuber commented 7 years ago

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.

kyamagu commented 7 years ago

@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.

CsatiZoltan commented 7 years ago

@kyamagu , @patrikhuber Thank you for the explanations.

patrikhuber commented 7 years ago

Cool, thanks @kyamagu!