|
Initialization and finalization are the
first and last pieces of code ever called. They are executed in dependency order
first, and in reverse of that for finalization. So unit a uses unit b = b.init then
a.init. You can do anything at all in
initialization where the code has scope. So you wouldn’t use the
Application Varaiable from here, because it hasn’t been created. You don’t always have to use
initialization to create and finalize to destroy. That would be very resource
hungry. Many times I would do something similar to
this. Function GetGlobalWhateverList:TList; Begin If globallist = nil then Globallist
:= TList.Create; Result := globallist; End Initialization Globallist := nil; Finalization FreeAndNil(GlobalList) You simply have to be aware of what exists
in memory at this point in time. From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul A Norman Point of interest - something basic for me and possibly others to
learn. I've only ever used unit 'initialization and finalization'
"blindly" since initialization finalization Otherwise I've used the onFormComplete
and onDestroy to
set intial stuff up and then release stuff. But I am guessing that Finailization
is a better place to release stuff (help
avoid memoery leakage under certain circumstances?), but Initialization would have to be used
for Finalization to
be acceptable.. I've read the Delphi 2005 help and googled a bit, but am not yet sure
just what sorts of code can be put in the Initialization and Finalization.
I was reading through a Unit the other day and saw all sorts
of things in Initialization
there that surprised me. Can any one please point me to a good reference on this, or in our new
learning sharing attitude, explain it for every ones benefit here? initialization |
_______________________________________________ Delphi mailing list [email protected] http://ns3.123.co.nz/mailman/listinfo/delphi
