Indeed! This code need finalize() now because heaptrc detect memory leak: procedure TForm1.Button1Click(Sender: TObject); var f: TMyRec; begin FillChar(f, SizeOf(TMyRec), 0); f.Field1 := 123; f.Field2 := 'abc'+IntToStr(f.Field1); push(@f);
system.Finalize(f); FillChar(f, SizeOf(TMyRec), 0); f.Field1 := 456; f.Field2 := 'vbnj'+IntToStr(f.Field1); push(@f); end; Although, leak is only when FillChar is called again. For example this is not leak: procedure TForm1.Button1Click(Sender: TObject); var f: TMyRec; begin FillChar(f, SizeOf(TMyRec), 0); f.Field1 := 123; f.Field2 := 'abc'+IntToStr(f.Field1); push(@f); f.Field1 := 456; f.Field2 := 'vbnj'+IntToStr(f.Field1); push(@f); f.Field1 := 789; f.Field2 := 'zzzz'+IntToStr(f.Field1); push(@f); end; Thanks Olivier for explanation
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal