GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming  >  Delphi

 Print  |  
Question:  what is a difference between free and destroy?



February 02, 2008 11:07:27 #1
 van_falen   Member Since: February 2008    Total Comments: 1 

RE: what is a difference between free and destroy?
 
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.

     

 

Back To Question