Re: Dynamic arrays of record/object



Hans-Peter Diettrich wrote:
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.

Actually, you want to move the expression "Data.Create" into the bitbucket. <g>

--
Rob
.


Quantcast