You can destroy an object explicitly, or you can let the IDL garbage collection system automatically destroy it.
The IDL garbage collection system will destroy an object when the object's last reference is destroyed. Specifically, IDL garbage collection calls the object’s Cleanup method. See Automatic Garbage Collection for more information.
To explicitly destroy an object, use the OBJ_DESTROY procedure. When an object is created using OBJ_NEW, memory is reserved for the object on the heap. An object must be destroyed in order to clean up the reference and remove the data from memory. Like automatic garbage collection, the OBJ_DESTROY procedure calls the object’s Cleanup method.
For example, if you have created an axis object called myAxis, use the following syntax to clean up the object reference: