Maximum number of threads per process in Linux?

前端 未结 16 2832
轮回少年
轮回少年 2020-11-22 02:16

What is the maximum number of threads that can be created by a process under Linux?

How (if possible) can this value be modified?

16条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 02:53

    Linux doesn't have a separate threads per process limit, just a limit on the total number of processes on the system (threads are essentially just processes with a shared address space on Linux) which you can view like this:

    cat /proc/sys/kernel/threads-max
    

    The default is the number of memory pages/4. You can increase this like:

    echo 100000 > /proc/sys/kernel/threads-max
    

    There is also a limit on the number of processes (and hence threads) that a single user may create, see ulimit/getrlimit for details regarding these limits.

提交回复
热议问题