title: "std::bad_alloc": am I using too much memory?
body: <p>The message:   </p>
  
  <pre><code>terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
  </code></pre>
  
  <p>I looked at the gdb backtrace and this is the lowest level method in there that I implemented myself:</p>
  
  <pre><code>/*
   * get an array of vec3s, which will be used for rendering the image
   */
  vec3 *MarchingCubes::getVertexNormalArray(){
      // Used the same array size technique as getVertexArray: we want indices to match     up
      vec3 *array = new vec3[this-&gt;meshPoints.getNumFaces() * 3]; //3 vertices per face
  
      int j=0;
      for (unsigned int i=0; i &lt; (this-&gt;meshPoints.getNumFaces() * 3); i++) {
          realVec normal = this-&gt;meshPoints.getNormalForVertex(i);
   //     PCReal* iter = normal.begin();
  
          if (normal.size() &gt;= 3) {
              array[j++] = vec3(normal[0], normal[1], normal[2]);
          }
          cout &lt;&lt; i &lt;&lt; " ";
      }
  
      return array;
  }
  </code></pre>
  
  <p>The cout statement you see above indicates that it terminates after 7000+ iterations.
  The above function is called only once near the end of my application. I call a very similar function before calling the above, that doesn't cause problems.</p>