title: Large 2D array gives segmentation fault
body: <p>I am writing some C++ code in Linux where I have declared a few 2D arrays like so:</p>
  
  <pre><code> double x[5000][500], y[5000][500], z[5000][500];
  </code></pre>
  
  <p>During compilation there is no error. When I execute it says "segmentation fault".</p>
  
  <p>Wen I reduce the size of the array from 5000 to 50, the program runs fine. How can I protect myself against this problem?</p>