inline var in Anonymous Thread cause memory leak [duplicate]

  

Delphi 10.4.1 running Firemonkey, Windows 64.
Why does declaring an inline var and using it in .Synchronize cause a Memory Leak?
Is this a bug or inline variables are not supposed to use in synchronize()? (in that case, inline shouldn’t this inline variable not be recognised by compiler inside synchronize()?
I can use other workarounds, but I’d like to understand this issue.
Attached is code that will demonstrate the memory leak.
procedure THeaderFooterForm.Button1Click(Sender: TObject);
begin
TThread.CreateAnonymousThread(
procedure
var
z, y : string;
//x : string; // this has no memory leak
begin
y := ’12’;
var x: string := ‘test’;

TThread.Synchronize(TThread.CurrentThread,
procedure ()
begin
z := x+y;
end);

end).Start;
end;

Comments are closed.