title: delete dynamically allocated memory in openGL
body: <p>I use C++ and and freeglut, and want to know how to delete the dynamically allocated memory using <code>new</code>. I need to free the memory when closing the window. Where should I put this <code>delete pointer</code>?  before <code>glutMainLoop()</code>? </p>
  
  <p>*<strong><em>Update</em>*</strong>.</p>
  
  <p>For example, I use <code>int *ptr = new int[n]</code> to store the vertex coordinates, and did not use class in the code. So I have to call <code>delete</code> in the <code>main()</code> to free the memory. I understand that I can use vector to do the same thing. But in my case, if I have to use <code>new</code>, how can I deallocate the memory? </p>