title: Android Drawing text with opengl es crashes after a few minutes
body: <p>I've created an opengl surface and everything works fine, however when I try to draw text onto it using the following method:</p>
  
  <pre><code>public void loadFPSTexture(GL10 gl){
  
      Bitmap bitmap = Bitmap.createBitmap(256, 256, Bitmap.Config.RGB_565);
      bitmap.eraseColor(Color.BLACK);
      Canvas canvas = new Canvas(bitmap);
  
      Paint textPaint = new Paint();
      textPaint.setTextSize(35);
      textPaint.setFakeBoldText(true);
      textPaint.setAntiAlias(true);
      textPaint.setARGB(255, 255, 255, 255);
      canvas.drawText("FPS "+reportedFramerate, 10,35, textPaint);
      gl.glGenTextures(1, texturesFPS, 0);
  
      gl.glBindTexture(GL10.GL_TEXTURE_2D, texturesFPS[0]);
      gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
      gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
  
      gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
      gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_REPEAT);
      GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
  
      bitmap.recycle();
  }
  </code></pre>
  
  <p>Then used in my onDraw function with:</p>
  
  <pre><code>gl.glPushMatrix();
  gl.glEnable(GL10.GL_TEXTURE_2D);
  gl.glBindTexture(GL10.GL_TEXTURE_2D, texturesFPS[0]);
  gl.glTranslatef(-surfaceSize.x/1.5f, surfaceSize.y/1.5f, 0.0f);
  gl.glScalef(10, 10, 1.0f);
  gl.glColor4f(1.0f, 1.0f, 1.0f, saturation_head); 
  gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
  gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
  gl.glVertexPointer(3, GL10.GL_FLOAT, 0,vertexBuffer);
  gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureFPSBuffer);
  gl.glDrawElements(GL10.GL_TRIANGLES, indices.length,GL10.GL_UNSIGNED_SHORT, indexBuffer);
  gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
  gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
  gl.glDisable(GL10.GL_TEXTURE_2D);
  gl.glPopMatrix();
  </code></pre>
  
  <p>I get a weird crash and the surface is unable to be drawn after this point. Logcat shows a constant stream of the following:</p>
  
  <pre><code>E/Adreno200-EGL( 2578): eglLockWindowSurface: failed to map the memory for fd=32 offs=1536000
  E/SurfaceFlinger( 2578): GL error 0x0505
  E/Adreno200-EGL( 2578): eglLockWindowSurface: failed to map the memory for fd=32 offs=1536000
  E/Adreno200-EGL( 2578): egliSwapWindowSurface: oglSwapBuffer failed
  E/SurfaceFlinger( 2578): eglSwapBuffers: EGL error 0x3003 (EGL_BAD_ALLOC)
  </code></pre>
  
  <p>I'm not sure why this is happening? any help would be much appreciated!</p>