linux - pthread_create() fails after 260 threads -


i have 500 threads want them run simultaneously. read default glibc allows 300 threads run simultaneously. how did got number? (i'm on 32 bit system)

the default stack size of thread on linux 10mb (or 8 on some). on 32 bit linux, user space applications have 3gb of memory address space, used shared libraries, heap, code, , other housekeeping, exhausting address space @ 260 threads(2.6gb memory) reasonable.

you can less space stack, create threads less stack space, e.g.

pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 1024*1000*2);  pthread_create(&tid, &attr, threadfunc, null); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -