Re: Dynamic arrays of record/object
- From: Hans-Peter Diettrich <DrDiettrich1@xxxxxxx>
- Date: Thu, 13 Mar 2008 17:15:23 +0100
sakkieLFS@xxxxxxxxx wrote:
procedure TForm1.Button1Click(Sender: TObject);
var Data: TXMLSectionData;
begin
Data.Create;
Data.AddSection('Header1','test data');
end;
The object in the local variable will be lost (memory leak) on exit from
the method :-(
Move the "var Data..." line into the form class, the "Data.Create" into
the form constructor, and add Data.Free to the form destructor.
If I declare this variable anywhere else besides local in the
eventhandler, it fails????
The statement should read:
Data := TXMLSectionData.Create;
regardless of where the Data variable resides.
DoDi
.
- References:
- Dynamic arrays of record/object
- From: sakkieLFS
- Re: Dynamic arrays of record/object
- From: Hans-Peter Diettrich
- Re: Dynamic arrays of record/object
- From: sakkieLFS
- Dynamic arrays of record/object
- Prev by Date: Re: Dynamic arrays of record/object
- Next by Date: Re: Dynamic arrays of record/object
- Previous by thread: Re: Dynamic arrays of record/object
- Next by thread: Re: Dynamic arrays of record/object
- Index(es):