Memory Management
To ensure that a plug-in does not cause instability in the 3ds Max, the following rules must be followed for all objects that may be shared from a plug-in with 3ds Max.
- A class or struct defined by the plug-in should inherit directly or indirectly from the
MaxHeapOperatorsclass. - Do not use custom allocation schemes (e.g. overloading operator
new, or using the placementnewoperator). - Use
MAX_malloc()and related operations frommaxheapdirect.hto allocate objects on the heap which are not derived fromMaxHeapOperatorsinstead of standard C memory handling routines such asmalloc.
Virtually every class and struct in the 3ds Max SDK has MaxHeapOperators as a base class, so inheriting from any of these classes assures that you have MaxHeapOperators as a base class. Although this can create a diamond-shaped inheritance pattern for types with multiple base classes, MaxHeapOperators uses only static member functions; name-resolution ambiguities should not occur.
These rules are important because objects shared with 3ds Max have to be allocated on a single shared heap managed by 3ds Max. For more information on what problem MaxHeapOperators is trying to solve see MSDN.
