Since my iOS app terminates (if running in debugger, the app simply freezes without any errors) after some minutes of intensive use, I started looking into possible reasons why the app would simply suddenly close down. (But always first do so after some time.)
I create lots of shortlived threads that are set to terminate when done. (I use FreeOnTerminate := True in constructor.) However, in Delphi IDE | Thread status the threads seem to live on after execute has run.
So in debug window, I have e.g. 100 threads with State=none and Status=unknown. Am I correct in assuming that means the threads are not completely freed/gone?
For reference, demo code:
constructor TMyOnlineThread.Create(...) ;
begin
inherited Create(False);
//--
//...
//--
FreeOnTerminate := True;
end;
destructor TMyOnlineThread.Destroy;
begin
//...
inherited;
end;
procedure TMyOnlineThread.Execute;
begin
//--
// Single task. No while loop or anything like that.
//--
if (...) then
begin
if Assigned(FOnDone) then
Synchronize(MyCallBack)
;
end
;
end;
procedure someothercode;
begin
TMyOnlineThread.Create(...);
end;