Re: Maximum number of processes in Linux

From: Michael Buesch
Date: Tue Aug 15 2006 - 19:39:40 EST

On Wednesday 16 August 2006 01:12, Robert Hancock wrote:
> Irfan Habib wrote:
> > Hi,
> >
> > What is the maximum number of process which can run simultaneously in
> > linux? I need to create an application which requires 40,000 threads.
> > I was testing with far fewer numbers than that, I was getting
> > exceptions in pthread_create
> What architecture is this? On a 32-bit architecture with a 2MB stack
> size (which I think is the default) you couldn't possibly create more
> than 2048 threads just because of stack space requirements. Reducing the
> stack size would get you more.

Hm, I'm on a 4way PPC64 machine with 2.5G RAM.
It can only create 509 pthreads and fails with ENOMEM
on the 510th.
That's not a really big machine, but I expected it to be able
to create somewhere around 8000 threads or so, at least. Especially
as it has a 64bit kernel and lots of memory.


That's my test app:

#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <errno.h>

static void * thread(void *arg)
while (1)

int main(void)
int err = 0;
unsigned long i = 0;
pthread_t t;

while (!err) {
err = pthread_create(&t, NULL, thread, NULL);
if (err) {
printf("Creating pthread %lu failed with \"%s\"\n",
i, strerror(errno));
printf("%lu pthreads created\n", i);

return 0;

Greetings Michael.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at