Share

MSharedPtr

MSharedPtr<> is a template class that is used to share objects between a plug-in and Maya. It behaves similarly to std::shared_ptr, and as with std::shared_Ptr, MSharedPtr<> keeps track of references to an object, and destroys and deallocates the object when there are no more references to it.

If an MSharedPtr<> is returned to you, you will need to maintain it. As with any other smart pointer, hold an MSharedPtr<> for any object you may want to reuse later. Maya will hold its own MSharedPtr<> for any objects it may use again later to prevent the objects from being destroyed and deallocated.

More than one MSharedPtr<> can point to the same object. However, you cannot have both an MSharedPtr<> and a std::shared_ptr pointing at the same object.

MSharedPtr<> is typically templated on proxy classes.

Was this information helpful?