gmurt / PentireFMX

Firemonkey components for Delphi
Apache License 2.0
71 stars 17 forks source link

ksInputList memory leak #8

Open Sniperxx opened 2 years ago

Sniperxx commented 2 years ago

Hi Graham, Under Windows and after closing the application a memory leak appear (ksInputList.pas) after some digging I've found some way to fix this:

destructor TksInputList.Destroy;
...
begin
  FScrollMonitor.Terminate;
  Sleep(300); // Adding this line will fix this problem
...

Sleeping 300 exactly is because the creation of FScrollMonitor thread in the while loop sleeps 200 so after terminating it we have to wait until the thread get out from sleeping and terminates itself.. before code processed to:

  for AItem in FItems do
  begin
    if AItem is TksInputListItemWithControl then
    begin
      c := (AItem as TksInputListItemWithControl).FControl;
      c.parent := nil;
    end;
  end;