Jenkins job run Failed with dynamic slave node which was created by clouds

When I build a job to build my project, I encountered the following error:

java.lang.OutOfMemoryError: unable to create new native thread: possibly out of memory or process/resource limits reached

This problem does not occur frequently, but it is sporadic. It may not appear again after executing the build again. Judging from the logs, the reason may be that the host where the k8s pod is built does not have enough threads to support the nodes to complete the build. Am I understanding this correctly? The problem seems inevitable. Is there some effective plan to avoid?

Try to add the resources block in your Jenkins pod definition file.