title: Deleting EGL Opengles 2.0 properly
body: <p>I've written a program that creates a window on WINCE and uses EGL to create the drawing surface and context. When this program quits, I have the following clean up routine: </p>
  
  <pre><code>eglMakeCurrent(m_eglDisplay,EGL_NO_SURFACE,EGL_NO_SURFACE,m_eglContext);
  eglDestroyContext(m_eglDisplay,m_eglContext);       
  glDeleteProgram(m_eglProgramObject);
  glReleaseShaderCompiler();
  
  delete m_eglDisplay;
  delete m_eglSurface;
  delete m_eglContext;
  delete m_eglConfig;
  </code></pre>
  
  <p>If I don't restart the target system, eventually the opening and closing of this program causes this following line to fail: </p>
  
  <pre><code>m_eglContext = eglCreateContext(m_eglDisplay,m_eglConfig,EGL_NO_CONTEXT,arrContextAttrib);
  </code></pre>
  
  <p>With EGL error 12291 which apparently means EGL_BAD_ALLOC. I assume there's some memory related to EGL that isn't being deleted properly every time the program exits but don't know what this could possibly be. Any suggestions? </p>