title: Thread creation failed: Resource temporarily unavailable
body: <p>I am running this C++ code using openMP.</p>
  
  <pre><code>#include &lt;float.h&gt;
  #include &lt;omp.h&gt;
  #include &lt;iostream&gt;
  
  double fRand(double fMin, double fMax);
  
  int main(int argc, char* argv[])
  {
  
  int columns = 20;
  int rows = 10000;
  
  //Create 2D array table
  double **table;
  table = (double**) malloc( rows * sizeof( double *) );
  for(int row=0; row&lt;rows; row++) {
      table[row] = (double*) malloc( columns * sizeof( double ) );
  }
  
  //Generate random numbers
  for(int i=0; i&lt;rows; i++) {
      for(int j=0; j&lt;columns; j++) {
          table[i][j]=fRand(0,1000);
      }
  }
  
  //Create 2D array P
  float **P;
  P = (float**) malloc(rows * sizeof(float*));
  for(int row=0; row&lt;rows; row++) {
      P[row] = (float*) malloc(rows * sizeof(float));
  }
  
  //Compute P elements
  #pragma omp parallel for schedule(dynamic)
  for(int i=0; i&lt;rows; i++) {
      for(int j=i+1; j&lt;rows; j++) {
          double d = 0;
          for(int k=0; k&lt;columns; k++) {
              double df = table[i][k] - table[j][k];
              d += df * df;
          }
          P[i][j] = (float) d;
      }
  }
  
  std::cout &lt;&lt; "Finish";
  
  }
  
  double fRand(double fMin, double fMax)
  {
       double f = (double)rand() / RAND_MAX;
       return fMin + f * (fMax - fMin);
  }
  </code></pre>
  
  <p>When the number of rows is small (~10000), it is running fine and is making use of all the cores. However, when running the algorithm with a larger number of rows such as rows=120000, it crashes and i get the following error:</p>
  
  <pre><code>libgomp: Thread creation failed: Resource temporarily unavailable
  </code></pre>
  
  <p>I tried to increase OMP_STACKSIZE but the error is still occuring.
  I am using windows 10 64-bit. I have 128Gb of RAM and CPU has 32 cores.
  I am compiling the code using the following command:</p>
  
  <pre><code> g++ -std=c++11 -fopenmp myfile.cpp
  </code></pre>