I have code like this:
ShowMessage(Memo1.Lines.GetText);
Delphi is telling me there is a leak caused by that code:
I try to fix it by using this code:
var
Message:string;
begin
Message := Memo1.Lines.GetText;
try
ShowMessage(Message);
finally
FreeAndNil(Message)
end;
it's working somehow, however the program is automatically force-closed after that.
Is there a way to avoid the memory leak in this case?
