开发者

Changing the limit of maximum number of pthreads by an application

Is it possible by any means to change the limit on the number of pthreads a process can create ? Currently on my linux system I can create around 380 threads but I want to increase that to say as long as memo开发者_如何学Pythonry is available.


reduce user's stack size 'ulimit -s 1024';

default: 8MB 
reduced: 1MB 

to increase number of threads.

set the stack size: pthread_attr_setstacksize(1024)


cat /proc/sys/kernel/threads-max

may work in Linux but not other UNIX systems. I thought the right way is

Maximum number of threads per process - sysconf(_SC_THREAD_THREADS_MAX) failing

which works on some UNIX systems (like HPUX) but not on Solaris or Linux...


Your problem is that you have not called pthread_detach on the threads in question. This tells pthread that the resources associated with each thread will be released when the thread terminates. You have to call either pthread_join or pthread_release on all threads to release thread resources. That means that you also have to call pthread_detach in your pthread_join cancellation handlers or leak.


Look at this:

Maximum number of threads per process in Linux?

And take a look at this as it might pertain to your question:

Serve one client with each server thread

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜