Destructor Function in Delphi - ablealias/Delphi GitHub Wiki

Destructors are using to free a class reference or object. The Destructor keyword defines a destructor procedure Destroy for a class. To free an object you must call the Destructor method. The Override directive must be specified since we are overriding the virtual TObject destroy method. At the end of a Destructor, you should call Inherited keyword to invoke the parent Destructor. The direct call to a Destructor passes True for the extra hidden parameter. This tells Delphi to call FreeInstance to free the object. If the Destructor calls an inherited destructor, Delphi passes False as the hidden parameter to prevent the inherited destructor from trying to free the same object. When freeing an object, you should call the Free method and not the Destructor. The distinction is important, because Free checks whether the object reference is nil and calls** **Destroy only for non-nil references.