Getting error "can't start new thread"

Hi,

We use Jenkins for QA automation purposes, we have around 200 nodes (real computers) and sometimes up to 200 jobs that can run in parallel on those nodes.
We are getting more and more often this error “can’t start new thread”, inside shell scripts in our jobs.

In the Jenkins monitor web page, I see this line at the end:
Threads on : Number = 1,068, Maximum = 1,508
And when the crash situation occurs, the thread number reaches the maximum, so I am pretty confident that this is our issue.

How can I increase the maximum thread so our jobs stop failing?

We are running Jenkins in a Docker container, and if there are command line parameters to send to Jenkins, I don’t really know how to change the Jenkins command line …

Thanks for your help

1 Like

Maybe this could help you? python - error: can't start new thread - Stack Overflow

Thanks
It does not seem to be linked to the system and to the user’s threads, it seems to be really internal to Jenkins and to the number of threads it’s allowed to run.

When I fully charge the server, very close to the moment we have issues, here are the results I have:
ps -fLu jenkins | wc -l : gives me something like 3300
ulimit -u :gives me 257444

And on the Monitor web page,
Threads on : Number = 1,460, Maximum = 1,508

Or this? https://www.baeldung.com/jvm-max-threads

Thanks,

It helped me understand where the parameters stand. I am in the process of changing and testing new parameters to solve the issue (a long process because only IT can do that).
I currently added -Xms4g -Xmx4g -XX:+UseG1GC to JAVA_ARGS.

1 Like