An error occurs when a large number of threads (2026 threads) are started using jrockit today:
Java code
Error starting thread: Resource temporarily unavailable
After in-depth queries, problems such as memory and handle count are eliminated, and it is no problem to switch to the root user to open a large number of threads. Try to adjust the ulimit parameters, and finally find that there is a problem with the "max user processes" parameter. by adjusting the size of the root user to 12000, the number of threads also increases.
Java code
Root @ blog:/home/badqiu # ulimit-
Core file size (blocks,-c) 0
Data seg size (kbytes,-d) unlimited
Scheduling priority (-e) 0
File size (blocks,-f) unlimited
Pending signals (-I) 143360
Max locked memory (kbytes,-l) 32
Max memory size (kbytes,-m) unlimited
Open File (-n) 2048
Pipe size (512 bytes,-p) 8
POSIX message queues (bytes,-q) 819200
Real-time priority (-r) 0
Stack size (kbytes,-s) 8192
Cpu time (seconds,-t) unlimited
Max user processes (-u) 2046
Virtual memory (kbytes,-v) unlimited
File locks (-x) unlimited
Takes effect in linux.
Vi/etc/security/limits. conf
Java code
* Soft nproc 12000
* Hard nproc 12000
Nproc is "max user processes", the complete description is: nproc-max number of processes
Parameter description:
The number of threads that a single user can start. Because a process also starts a thread, the number of processes is indirectly limited.
Note:
This parameter is only useful to common users, and root users are not limited here. Therefore, the root user can start tens of thousands of threads and cannot reproduce this problem.