How Many Threads Can a Single Linux Process Create?
The article explains Linux virtual memory layout, shows that a 32‑bit process can create roughly 380 threads due to an 8 MB default stack, while a 64‑bit process can theoretically spawn millions of threads but is constrained by kernel parameters such as threads‑max, pid_max and max_map_count.
Linux splits the virtual address space into kernel and user regions; on 32‑bit systems the kernel occupies the top 1 GB and the remaining 3 GB is available to user processes, while on 64‑bit systems each region can span up to 128 TB, though only 48 bits are currently used (256 TB total).
The user address space is divided into several segments: a reserved low‑address region, code, data, BSS, a heap that grows upward, a mmap area for dynamic libraries and shared memory, and a stack that grows downward. The stack size is fixed by default at 8 MB, but can be changed via system parameters.
Each new thread requires its own stack. Running ulimit -a shows the default stack size; on many Linux distributions it is 8 MB. The article demonstrates this with the command: [ecs-user@iZ2ze923utbhhwxwgc0pd9Z ~]$ ulimit -s 512 On a 32‑bit system the usable user virtual memory is 3 GB, so the maximum number of threads is roughly 3 GB / 8 MB ≈ 380. Reducing the per‑thread stack size (e.g., to 512 KB) can increase the theoretical limit.
On a 64‑bit system the user virtual memory can be as large as 128 TB, which would allow over ten million threads (128 TB / 8 MB). In practice, the creation of threads is limited by kernel parameters:
/proc/sys/kernel/threads-max – maximum total threads the kernel supports (default 14553).
/proc/sys/kernel/pid_max – maximum PID value, affecting threads as they each have a PID (default 32768).
/proc/sys/vm/max_map_count – maximum number of virtual memory areas a process may have (default 65530), which can also restrict thread creation.
Therefore, while a 64‑bit process is not constrained by virtual memory size, it is bounded by these system limits and by performance considerations.
In summary, a 32‑bit Linux process can create about 380 threads with the default 8 MB stack, whereas a 64‑bit process can theoretically create millions of threads but is practically limited by kernel configuration parameters rather than address space.
Linux Tech Enthusiast
Focused on sharing practical Linux technology content, covering Linux fundamentals, applications, tools, as well as databases, operating systems, network security, and other technical knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
