I downloaded the code, modified and tested on Ubuntu Mate 23.10. This is the test result:
- Starting the code the memory usage was 1.3 GB
- After clicking the button, the memory usage was 1.4 GB
- After I manually closing the forms, the memory usage was 1.3 GB
If your computer's memory usage didn't return to its previous size after closing the forms, probably because:
- OS related behavior
- You use too few samples
This is the code I added:
procedure TForm1.Button1Click(Sender: TObject);
var
NewForm: TForm2;
i: Integer;
begin
for i := 0 to 99 do
begin
NewForm := TForm2.Create(Self);
NewForm.Color := Random($FFFFFF);
NewForm.Show;
end;
end;
------
Oops, I'm too late. Leledumbo already provided the answer.