[fpc-devel] TCustomApplication's parent class?
nc-gaertnma at netcologne.de
Sat Apr 26 12:19:28 CEST 2008
On Sat, 26 Apr 2008 11:58:55 +0200
"Graeme Geldenhuys" <graemeg.lists at gmail.com> wrote:
> 2008/4/26 Vincent Snijders <vsnijders at quicknet.nl>:
> > It most probably is not unknown to you: the most important benefit
> > of being TComponent is that you can be owner of other components,
> > so that eases memory management. The Application can become
> > responsible for freeing the components it owns.
> OK, the owner idea is handy, but what other than Forms or DataModules
> would Application want to own?
TCustomApplication is not only for LCL. For example cgi applications.
> I've just changed fpGUI so that it's Application class descends from
> TObject, and maintains an internal list (TList) of objects created via
> Application.CreateForm(). I've had constant memory leaks I couldn't
> track down, but changing Application to a TObject and maintaining the
> internal list myself fixed all the memory leak issues.
Maybe you freed in the wrong order.
The position of the 'inherited Destroy' call in TApplication.Destroy
may be important.
> Maybe my understanding of TComponent's ability to free owned objects
> are lacking. Is there something special I was supposed to do, so that
> TComponent can free off any owned objects?
Probably you did too much.
Don't double free components.
You can check with csDestroying in ComponentState.
More information about the fpc-devel