Bridges > COM Import Bridge and ActiveX > COM Import Bridge > Destroying IDLcomIDispatch Objects

# Destroying IDLcomIDispatch Objects

Use the OBJ_DESTROY procedure to destroy and IDLcomIDispatch object.

When OBJ_DESTROY is called with an IDLcomIDispatch object as an argument, the underlying reference to the COM object is released and IDL resources relating to that object are freed.

Note: Destroying an IDLcomIDispatch object does not automatically cause the destruction of the underlying COM object. COM employs a reference-counting methodology and expects the COM object to destroy itself when there are no remaining references. When an IDLcomIDispatch object is destroyed, IDL simply decrements the reference count on the underlying COM object.

Note: IDL does not automatically destroy an object when the object variable goes out of scope (e.g., when a procedure returns). If the IDLcomIDispatch object is not explicitly destroyed, the COM reference count is not decremented, which could keep the object instantiated and never released.