> Subject for discussion - when dynamically creating a components
>
> Should I
>
> a/ Set the owner to nil and destroy it myself
> b/ Set the owner the same as the parent
> c/ Set the owner as the form
This is entirely dependant upon the intended lifetime of the component.
1. if it lives within a single method call. No Owner, free it yourself using
a finally block.
2. if the lifetime exactly follows the parent then owner=parent.
3. if its lifetime follows that of an object not it's parent and that object is
not responsible for the release of your parent then Owner = object.
Owner = form is a simple model to simplify the streaming process. Objects
should be quite capable of having Owner=parent unless the object is supposed
to be released before or after the parent.
My guidelines are:
- The only excuses for consuming memory are UI response and performance.
- Release as soon as possbile - memory is valuable.
- Some components are expensive to recreate regularly, instance pooling
may speed things up - Lifetimes are managed by the instance pool.
--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz