OpenGL memory problem

I’m having problems freeing up memory in my opengl app. i’m creating a landscape scene with all the vertices and 2 textures. I then try and delete everything and reload it while the app is running to see if all memory is freed correctly. Right now it is not.

If I load only the terrain data with no points memory is freed correctly and no more memory is used. I’m using Windows XP’s Process Viewer to see mem usage.

But then if I load the textures and try reloading the scene another 4.5 MB is tacked on. Since I’m using a 1024x1024 and a 512x512 texture map. I use glDeleteTextures(1, &texture) for each of the textures but it doesn’t seem to free the memory. Plus I’m pretty sure they’re being loaded into system ram since the amount of mem usage varies when I don’t use textures.

Anyone have any ideas on how to free this memory or fix this problem?

I think your problem isn’t OpenGl-relevated, as glDeleteTextures only frees memory that has been allocated for textures in VRAM (or RAM if your texture has been put there via AGP).
So I think there’s something wrong with your texture loading, and you maybe just allocate memory for the texturefile and then forget to free it after you have uploaded the texture to OpenGL.

What card? What driver version?

Note that a system memory copy of alive texture objects is more or less required anyway. OpenGL allows you to overflow your video card memory and thus needs to manage the textures that won’t fit. The system mem copy allows the driver to simply reload textures to the graphics card, which is orders of magnitudes faster than true texture swapping (ie, transferring data in to-be-replaced vid mem regions back to system memory first).

I may be terribly off here, but in dynamic memory management situations I’ve found it useful to keep a pool of memory around for later use, once allocated. That’s been good for me to anticipate further memory allocations made by a client app.

If that’s what your GL driver is doing, then memory consumption shouldn’t increase further when creating another texture w same properties. Can you try to test this?