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.

  1. A class or struct defined by the plug-in should inherit directly or indirectly from the MaxHeapOperators class.
  2. Do not use custom allocation schemes (e.g. overloading operator new, or using the placement new operator).
  3. Use MAX_malloc() and related operations from maxheapdirect.h to allocate objects on the heap which are not derived from MaxHeapOperators instead of standard C memory handling routines such as malloc.

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.