glDeleteTextures Memory Leak

Hi Experts,

Hardware:BXS 4-64 MC1

I found a memory leak problem about texture load in the opengl driver, below is my test

We have 4 ASTC image, every ASTC<100k, test case is:
step1: glGenTextures
step2: glCompressedTexImage2D
step3: render
step4: glDeleteTextures

Complete 4 steps in a sec and repeat 600 times, we will see glerror 505 (memory leak) reported
I make sure I released the texture resources normally, It seems that glDeleteTextures just tells the opengl driver not to use the texture, but it does not release the resources immediately.
But even so, I don’t know when it will be released. Do you know how to force the release of resources, or have you encountered similar problems?

Hi axel,

After consulting the OpenGL ES Driver Team, the OpenGL and OpenGL ES specifications mention that the underlying object will not be deleted until it is no longer in use. Deletion is managed in a separate thread.

For your code to work correctly, you should use sync objects (see Sync Object - OpenGL Wiki ). One option is to use a Fence sync object after the glDeleteTextures call. The sync object will be added to the command stream on creation. Later you can use glWaitSync or glClientWaitSync to know when the fence has been signaled, and then you will have the certainty from the CPU side that the glDeleteTextures call was completed. You should also keep track on how much GPU memory you are using.

Best regards,
Alejandro

Hi AlejandroC,

Thanks for your reply!

I found another phenomenon. Please help to confirm whether it is normal.

Old platform: SGX544
step1: id1 = glGenTextures()
step2: glCompressedTexImage2D
step3: render
step4: glDeleteTextures(id1)
step5: id2 = glGenTextures()

In this test case, we print the id, id1 == id2

Our new platform: BXS 4-64 MC1
step1: id1 = glGenTextures()
step2: glCompressedTexImage2D
step3: render
step4: glDeleteTextures(id1)
step5: id2 = glGenTextures()

In this test case, we print the id, id1 != id2, id2 always a new id

I am not sure if this is normal, it’s seems id1 is not released

Hi axel,

Thanks for your question.

The drivers in SGX544 and BXS 4-64 MC1 are most likely different. OpenGL IDs can be reused. For the case of BXS 4-64 MC1 having id1 != id2, it might mean the texture generated in step1 is still not released. I recommend you to look into sync objects as described in my previous message if you want to know when the command glDeleteTextures(id1) from step4 has been completed.

Best regards,
Alejandro