What is a difference between free and destroy?

Showing Answers 1 - 3 of 3 Answers

van_falen

  • Feb 13th, 2008
 

If you write your own code to instantiate objects, you are responsible for disposing of them as well. Every object inherits a Destroy method (called a destructor) from TObject. To destroy an object, however, you should call the Free method (also inherited from TObject), because Free checks for a nil reference before calling Destroy. For example,

Employee.Free;

destroys the Employee object and deallocates its memory.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions