<p>Recently we were getting the following exception in one of our Containers which was running a Java application in Openshift 4.2. This container used to run perfectly on Openshift 3.11.</p>

<pre><code>Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:717
</code></pre>

<p>Within the containers, the ulimits looks perfectly fine. See the below image.</p>

<p><a href="https://i.stack.imgur.com/Rytje.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rytje.png" alt="Ulimits"></a></p>

<p>In Openshift 3.11 the same container could create 4096 Threads. But in Openshift 4.2 it just can create 1024 threads. Please see the Below Images,</p>

<p>OCP 3.11
<a href="https://i.stack.imgur.com/EyE8b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EyE8b.png" alt="Openshift 3.11"></a></p>

<p>OCP 4.2
<a href="https://i.stack.imgur.com/dTXeU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dTXeU.png" alt="enter image description here"></a></p>

<p>From the above ulimits it's evident that docker agent level configurations are done. Also, I have allocated enough memory for OS to create native threads. But I have no clue where this limit is set. How can I increase this global limit? Thanks in advance. </p>

<p>By default, OpenShift 3 uses <em>docker</em> as container runtime whereas OpenShift 4 uses <a href="https://cri-o.io/" rel="nofollow noreferrer">cri-o</a> as container runtime.</p>

<p>According to <a href="https://github.com/cri-o/cri-o/issues/1921" rel="nofollow noreferrer">Default pids_limit too low</a> - by default there has been a limit to 1024 threads when using cri-o.</p>
