Routines (alphabetical) > Routines: O > OBJ_DESTROY

# OBJ_DESTROY

The OBJ_DESTROY procedure is used to destroy an object. If the class (or one of its superclasses) supplies a procedure method named CLEANUP, the method is called and all arguments and keywords passed by the user are passed to it. This method should perform any required cleanup on the object and return. Whether a CLEANUP method actually exists or not, IDL will destroy the heap variable representing the object and return.

Note: OBJ_DESTROY does not recurse. That is, if `object1` contains a reference to `object2`, destroying `object1` will not destroy `object2`. Take care not to lose the only reference to an object by destroying an object that contains that reference. Recursive cleanup of object hierarchies is a good job for a CLEANUP method.

If you want to destroy objects automatically, see Automatic Garbage Collection.

## Syntax

OBJ_DESTROY, ObjRef [, Arg1, …, Argn]

## Arguments

### ObjRef

The object reference for the object to be destroyed. ObjRef can be an array, in which case all of the specified objects are destroyed in turn. If the NULL object reference is passed, OBJ_DESTROY ignores it quietly.

### Arg1…Argn

Any arguments accepted by the CLEANUP method for the object being destroyed can be specified as additional arguments to OBJ_DESTROY.

## Keywords

Any keywords accepted by the CLEANUP method for the object being destroyed can be specified as keywords to OBJ_DESTROY.

## Version History

5.0 | Introduced

## See Also

OBJ_NEW, OBJ_VALID