NPTL caps maximum threads at 65528?

前端 未结 4 1144
暖寄归人
暖寄归人 2020-12-30 15:43

The following code is supposed to make 100,000 threads:

/* compile with:   gcc -lpthread -o thread-limit thread-limit.c */
/* originally from: http://www.vol         


        
4条回答
  •  清酒与你
    2020-12-30 15:53

    pilcrow's mention of /proc/sys/vm/max_map_count is right on track; raising this value allows more threads to be opened; not sure of the exact formula involved, but a 1mil+ value allows for some 300k+ threads.

    (For anyone else experimenting with 100k+ threads, do look at pthread_create's mmap issues... making new threads gets really slow really fast when lower memory is used up.)

提交回复
热议问题