Hello,

I think I have a similar problem to this one: 5305-A-Question-about-glTexImage2D()-and-using-memory (I'm not allowing to post the whole URL since this is my first post)
but the solution described there (using glBindTextures after a glDeleteTexture to force the texture memory to be freed) did not seem to work in my case, and the thread is closed, so I created this one.

We have a cross-platform game engine, which uses OpenGLES for its iOS and Android versions. Our games frequently create new textures and delete textures because of their nature (point&click games, every image has to be deleted then new ones be loaded at every scene change). We did not have any problem until we tested it on a Kindle Fire HDX, which holds an Adreno 330. The problem seems to exist also on the versions of the Galaxy S3 that holds an Adreno 330 (northern-american ones).

On this hardware, there seems to be a leak, either at texture allocation or deleting, that causes the application to crash every 10-15 minutes.

Basically, every time we know we will need a new texture, we generate a new texture ID:
Code :
glGenTextures(1, &mTexId);
glBindTexture(GL_TEXTURE_2D, mTexId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

after loading an image, we provide it to OpenGL:

Code :
glBindTexture(GL_TEXTURE_2D, mTexId);
...
case IF_R8G8B8A8:
{
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mVRAMWidth, mVRAMHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, img.bufferWidth(), img.bufferHeight(), GL_RGBA, GL_UNSIGNED_BYTE, buffer);
    break;
}
....

When we enter a new scene, the first thing we do is freeing everything we did in the previous scene, including textures:
Code :
glDeleteTextures(1, &mTexId);

I checked that the textures were deleted in the same thread as the one in which the egl context was made current, which seems like a frequent fix for this problem. Except that I'm not sure the whole textures are leaking (otherwise when leaving a scene I should have a 20MB leak, I never have more that a 5MB leak at once), and our engine is mostly single-threaded, so this is not likely to happen.

I tried to reuse texture IDs, or even keeping already allocated textures to use them for textures of the same size. The first solution did not make any difference, and I think I didn't implement the second one carefully enough for it to work (this was supposed to be a last-minute fix... and the game in question uses textures of very varying sizes, so it might actually not be very efficient).

As I said, to this day, this problem only occurred on devices using an Adreno 330, so I suspect a bug in the driver. I already posted on the Qualcomm forums, but the answers are not frequent. Is there a known workaround for this kind of issue?

Thanks in advance for your answers,

Guntha