Article View: comp.lang.pascal.delphi.misc
Article #512Re: tList.destroy
From: Cybercat
Date: Sun, 10 May 1998 00:00
Date: Sun, 10 May 1998 00:00
41 lines
2071 bytes
2071 bytes
On Sat, 09 May 1998 17:31:24 GMT, ullrich@math.okstate.edu wrote: >In article <pacsoftEsnnEB.2nE@netcom.com>, > pacsoft@netcom.com (Wilhelm Sarasalo) wrote: >> >> A long time ago I looked at the source for tList.Destroy and it didn't >> seem right because it overrode tObject.Destroy, but didn't call it, it >> just called clear that sets count and capacity to 0. >> >> Now I bought a debugging tool called BoundsChecker from NuMega. It >> reported resource leakage where I had tList.create/tList.free pairs. >> >> I modified classes.pas adding inherited destroy to tList.destroy, >> BoundsChecker quit reporting any leakage. Programs didn't change their >> behavior. > > TList descends directly from TObject. TObject's Destroy method >doesn't do anything, so the program behaves the same whether >inherited Destroy is called or not. (The 32 bytes(?) allocated >for _any_ object gets freed by _any_ destructor, and there's >nothing else for TObject.Destroy to do.) > > Evidently BoundsChecker doesn't understand this. It is also possible that Wilhelm simply forgot that TList doesn't destroy any objects to which it may point. For example, var MyList: TList; TestObj: TObject; begin MyList := TList.Create; TestObj := TObject.Create; MyList.Add(TestObj); MyList.Free end; will cause a leak, since TestObj is never freed. Could this be the cause of his problem?
Technical Details
Message-ID:
<35551513.72185262@news.mia.bellsouth.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<pacsoftEsnnEB.2nE@netcom.com> <6j23tc$bjk$1@nnrp1.dejanews.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10baee,f5046dff2f7b01e1 X-Google-Attributes: gid10baee,public X-Google-Thread: fb0ea,f5046dff2f7b01e1 X-Google-Attributes: gidfb0ea,public From: MauriceV@bellsouth.net (Cybercat) Subject: Re: tList.destroy Date: 1998/05/10 Message-ID: <35551513.72185262@news.mia.bellsouth.net> X-Deja-AN: 351856944 References: <pacsoftEsnnEB.2nE@netcom.com> <6j23tc$bjk$1@nnrp1.dejanews.com> NNTP-Posting-Date: Sat, 09 May 1998 22:50:47 EST Reply-To: MauriceV@bellsouth.net Organization: Fundi Software Newsgroups: comp.lang.pascal.delphi.misc,borland.public.delphi.vcl.components.using