Reference Object Lifetime Management
 
 
 

Objects managed by the 3ds reference system, are normally destroyed automatically when there are no more strong references to them. One exception to this are nodes (INode) which can be deleted by a user. Occasionally user code needs to destroy objects derived directly or indirectly from class Animatable, ReferenceMaker, or ReferenceTarget.

When these objects are destroyed by calling the delete operator on a pointer to them, the reference links between these objects are not properly disconnected, which can make 3ds Max unstable.

To make it easier for plug-ins to use the correct method of destroying objects via pointers to class Animatable, ReferenceMaker or ReferenceTarget, the destructor of these classes has been made protected. As a side effect, instances of these classes cannot be stack based. That means they cannot be allocated on the stack or passed by value as function parameters.

Never use operator delete directly on a plug-in instance, or any instance of classes derived from class Animatable, class ReferenceMaker, and class ReferenceTarget. Instead use one of the following techniques for deleting objects:

When an object is deleted via ReferenceTarget::MaybeAutoDelete() or ReferenceMaker::DeleteMe() all of the dependent are notified, the reference are deleted, and undo is handled properly.