Hi Desperado,
Apologies for the delay, I’ve looked into the specification(found here) for GL ES. Navigate to section 5.1.3 for the details on “Deleted Object and Object Name Lifetimes” for more information. I have also spoken to the driver team as well, and there is a list of things to consider.
First and foremost, the DDK does not keep caches of memory, it is freed immediately when it is no longer in use. However there is a reason that you might not immediately see the VRam get returned to the OS, Sometimes the memory is managed, meaning if the driver is expecting to reallocate that memory for something else, it will maintain ownership of the memory, because it is faster to hold onto that memory and reallocate, rather than doing a deallocate then reallocate cycle.
Further, I wanted to address something from another post about how you are gathering Vram usage statistics. inside of /sys/kernel/debug/pvr/driver_stats
where you are gathering statistics per PID. These statistics are generated by your vendors implementation of the DDK and can differ from ours, further memory that has been freed, but not released back to the OS might not be reflected in these driver statistics.
The counter MemoryUsageTotal
does not correspond to a counter in our base DDK. Most likely MemoryUsageTotal
is likely not the current Vram usage, instead it is likely a meta counter representing the driver’s total memory footprint, or some other form of sum; for example it could be a sum of all memory used so far, exactly what it’s purpose is, we cannot say for certain. If you wanted to use the current method for gathering Vram usage, then the counter MemoryUsageAllocGPUMemUMA
most likely will give you a better estimate of the current Vram usage, but it will not give you an exact value.
If you are still seeing a memory leak, then this could be a problem with how frequently the statistics in that file are updated, or the buffer might not be being released because it is marked as still in use.
When you call glDeleteBuffers
or glDeleteTextures
it is not guarenteed that the memory will be released right away, just that the name (that’s the GLuint ID) is immediately invalidated. The underlying object is marked for delete when it is no longer in use, you can see this in the GL ES specification linked above. A buffer or texture is considered in use when it is still referenced in a container object (ie a texture contained in a framebuffer, or a buffer in a VAO), or if that resource is currently bound to any context. Note that when you make a call to a delete function, the object will only be unbound from currently active contexts. So it is possible that you are not releasing all the references to the object that you are trying to delete, and thus the object stays “in use”.
Finally there is one known possibly leaking bug that we have encountered before in DDK 1.10, that some internal memory is being incremented. This occurs when an application repeatedly uses glBindFramebuffer
→ glClear
and then does not use that framebuffer texture. There is a chance your application can be effected by this bug.
If you exhaust all these options than you can send us a ticket with the application binary, and using one of our internal tools we can attempt to track the VRam usage for you.
All the best,
Lawrence