The thread limit for linux is limited , and you can change it by completing the required limit to /proc/sys/kernel/threads-max . The default value is calculated from the available system memory. In addition to this limit, there is another limit: /proc/sys/vm/max_map_count , which limits the maximum mmapped segments and at least the latest kernels will write memory to the stream. It should be safe to increase this limit if you hit it.
The limitation you click on is the lack of virtual memory on a 32-bit operating system. Install 64-bit Linux, if your hardware supports it, and everything will be fine. I can easily start 30,000 threads with a stack size of 8 MB. The system has one Core 2 Duo + 8 GB system memory (I use 5 GB at the same time for other things), and it works with 64-bit Ubuntu with a 2.6.32 kernel. Please note that overcommit memory (/ proc / sys / vm / overcommit_memory) must be enabled, because otherwise the system will need at least 240 GB of memory (the sum of real memory and swap space).
If you need a lot of threads and you cannot use a 64-bit system, the only choice is to minimize the memory usage in the stream to save virtual memory. Start by querying as a small stack that you can live with.
Mikko antalainen
source share