Ross,

Simple rule - if you create the object, make sure you free it (in the right
place and in the right order).  Exceptions to the rule:

1.  TComponent can be freed by its owner - but in general I clean that up
anyway (make sure you Free it before you free the owner).

2.  TCollectionItem objects are free by TCollection - this is how the
TCollection framework works.  You can still choose to free TCollectionItem
individually if you desire (but make sure you do it before you free the
TCollection).

If you don't feel like freeing objects, then program in Java or C# (D-flat),
or use interfaces (be careful how you reference the interface).

Don't rely on Windows cleaning up after you because I know for sure that not
only does it not clean up properly.  How many times have you "killed" Word
(that has hung) and find that the DOC file is locked?

There are even instances when you do explicitly release resources, Windows
"forgets" to release it for you.

Regards,
Dennis.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 19 July 2001 12:26
> To: Multiple recipients of list delphi
> Subject: [DUG]: Destroying Objects
>
>
> A simple question.
>
> When an application exits in the normal way, does it automatically
> destroy all objects created at runtime?
>
> Cheers,
> Ross.
>
>
> ------------------------------------------------------------------
> ---------
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to