On Thursday, 24 September 2015 at 08:55:25 UTC, Alex wrote:
This should be a not so long question to answer, I hope.

I took an example from the "Programming in D" book, chapter "Message Passing Concurrency", around page 550. The question of interest was, how many threads I can have spawned at the same time. So I made an array of robot objects from the example and found out: the maximum number is different on different PCs I have.
For example:
- on my mac I can have 2048 threads spawned at the same time
- on my linux machine the maximum number is 32192.
The numbers are quite fixed, however there were some small fluctuations on the linux machine.

The questions still remains: how do I know, what maximum number of threads I can have? Is it possible to calculate this value during runtime of my program? The two machines I have available for testing are very different, what is the main parameter which controls the number of possible threads? (CPU maybe? Number of cores? RAM is not I think at the moment...)

Thanks in advance
Alex

From the numbers (2048 = 2^11, 32192 = ca 2^15), it's clear that you're not running out of memory, but that these are artificial limits imposed by the OS.

This stackoverflow answer describes the situation on Linux:
http://unix.stackexchange.com/a/47600/34768

Reply via email to