Forum > Windows

Windows Threads Total Limit

(1/3) > >>

Nick N.:
Hi all

I have A simple test, creating and terminating lot og threads. On my PC this test working without errors. On several clints PC code fails after 100K - 500K cycles.

Thread creation error: Not enough memory resources are available to process this command.

Code:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure Empty;begin  //end; procedure TForm1.Button1Click(Sender: TObject);Var s : string;    tc, i, j, no : integer;    thread : TThread;    list : TList;begin    no := 0;  List := TList.Create;   s := '1000000';  if not InputQuery('Enter number of queries', '', s) then exit;  tc := StrToInt(s);   for i := 1 to tc div 500 do  begin     Caption := 'STRESS TEST: ' + inttostr(no);    Application.ProcessMessages;     List.Clear;     for j := 1 to 500 do    begin      inc(no);       Thread := TThread.CreateAnonymousThread(@empty);       thread.FreeOnTerminate := false;      thread.Start;      List.Add(thread)    end;     while list.Count > 0 do    begin     TThread(List[0]).WaitFor;     TThread(List[0]).Free;     List.Delete(0);    end;   end; end;  
Does Windows have a maximum limit on the total number of threads created? Can I disable it ?

Tnx

skalogryz:

--- Quote from: Nick N. on July 23, 2021, 10:41:38 pm ---Thread creation error: Not enough memory resources are available to process this command.

--- End quote ---
are you trying 32-bit or 64-bit? something to read

Nick N.:

--- Quote from: skalogryz on July 23, 2021, 11:02:13 pm ---
--- Quote from: Nick N. on July 23, 2021, 10:41:38 pm ---Thread creation error: Not enough memory resources are available to process this command.

--- End quote ---
are you trying 32-bit or 64-bit? something to read

--- End quote ---

I use 32bit. Yes, I read this article too.

I still can't figure out why the error occurs on some PC. In my case, threads are created and destroyed, there can be no more than 500 threads at the same time. Everything works for me locally without failures, on the test machine after a while the error of creating new threads starts to appear

Gustavo 'Gus' Carreno:
Hey Nick,


--- Quote from: Nick N. on July 23, 2021, 10:41:38 pm ---Thread creation error: Not enough memory resources are available to process this command.

--- End quote ---

On the risk of seeming pedantic, and my apologies if you read it like that, it's not my intention, but the error message mentions memory.

Can you please provide us with the RAM amount for both the test machine and the client machine?

If both have the same amount, then please ignore my post.
But if the amount differs by a big amount, well, that could be your problem.

Also, are both machines running the same version of Windows? And I mean the same, cuz Windows Home and Windows Pro have some differences that can affect memory handling., I think...

Cheers,
Gus

Nick N.:

--- Quote from: Gustavo 'Gus' Carreno on July 24, 2021, 04:42:00 pm ---Can you please provide us with the RAM amount for both the test machine and the client machine?

--- End quote ---

I have Windows 10 Pro, 16 GB ram. Test PC is virtual, windows server 2019, 8GB ram.

I tested the code on different computers, somewhere it works, somewhere it doesn't. There are enough system resources, 100 threads are 1GB of system memory, there is enough of this everywhere.

This code also not working in Delphi XE3 and 10.4.2 (latest)

Navigation

[0] Message Index

[#] Next page

Go to full version