I have memory leaks when close my application, when an user stopped the program with ThreadPool.CancelAll
The code:
procedure MyWorker(const task: IOmniTask);
begin
Form1.Log(Format('Task started ID=%d Name=%s', [task.UniqueID, task.Name]));
Sleep(2000);
end;
procedure TForm1.btnCreateClick(Sender: TObject);
var
i: integer;
begin
GlobalOmniThreadPool.MaxExecuting := 5;
for i := 0 to 100 do begin
CreateTask(MyWorker, 'Test task #' + IntToStr(i))
.Unobserved
.Schedule;
end;
Log('Tasks are sheduled...');
end;
procedure TForm1.btnCancelClick(Sender: TObject);
begin
GlobalOmniThreadPool.CancelAll;
end;
In Test.dpr:
ReportMemoryLeaksOnShutdown := DebugHook <> 0;
Press Create, Cancel, and close the window.