I have been having some problems with my openGL application running out of memory and I am trying to track down my problem. To this end, I created a small test program that bas
Windows OpenGL drivers are designed on the assumption that your code will actually draw stuff at some point. Because of that, they tend to avoid doing things exactly when you ask them to be done, deferring them to a more convenient time. And that's what you're running into here.
Just because you tell OpenGL that you're done with a texture object doesn't mean that OpenGL must immediately relinquish that memory. Doing that generally requires some pretty heavy-weight operations. So instead, drivers will defer this until later.
The problem is that "later" is usually defined as some form of glDraw*
command, glEnd
, glFlush/Finish
, or a swap buffer command. Or something of that nature. If all you do is sit in a loop and create/delete textures, the driver may not get the chance to actually delete anything.
Try making your test less artificial. Add a glFinish
after each glDeleteTextures
. If that doesn't work, draw stuff between deletions.
Ultimately, you cannot force drivers to do what you want. All you can do is make your test application behave more like a normal application.