Try OpenEdge Now
skip to main content
Object-oriented Programming
Designing Objects: Inheritance, Polymorphism, and Delegation : Class hierarchies and inheritance : Deleting an object

Deleting an object

A class-based, ABL object is either automatically deleted by the AVM during garbage collection when its reference count goes to zero, or manually deleted by the application using the DELETE OBJECT statement. In either case, the destructors (if any) for every class in the hierarchy are automatically run, from the bottom of the class hierarchy to the top.
Refer once again to this sample class hierarchy:
Progress.Lang.Object             <--- Top of hierarchy
      acme.myObjs.NECustObj      <--- Bottom of hierarchy
The DELETE OBJECT statement for an instance of acme.myObjs.NECustObj invokes the NECustObj( ) destructor, if it has one, followed by the CustObj( ) destructor, followed by the CommonObj( ) destructor and finally the implicit destructor for the built-in root class, Progress.Lang.Object. The AVM executes all these destructors automatically. You do not use the SUPER statement in a destructor. Remember that a destructor is always public and it can have no parameters.
For more information about garbage collection and the DELETE OBJECT statement, see Managing the object life-cycle.
Unlike constructors, the destructors in the class hierarchy execute to completion from bottom to top. When an object is instantiated, code in its constructors must execute from the top down to initialize super class resources that might be referenced by a subclass. By contrast, the destructors have the opportunity to free resources created by a subclass before it terminates and passes control to its super class for further clean-up, which has no knowledge of or need to reference its subclass.