Reputation: 9622
I am testing an OpenGL application and I am purposely not deleting a lot of OpenGL constructs to check for memory leaks.
For example I created an array of multiple shaders and never called glDeleteShader()
However valgrind reports no memory leaks,
Is it that valgrind is unable to detect these memory leaks, or is it that there is some garbage collector going behind my back ensuring no such leaks happen?
Upvotes: 3
Views: 1912
Reputation: 162297
However valgrind reports no memory leaks
That is because the default configuration of Valgrind blacklists OpenGL from being profiled. This is for a simple reason: Most OpenGL implementations do garbage collect their objects. When you do a call to glDelete…
then all what happens is, that the "externally" accessible object names/IDs are being disassociated from the actual internal representations.
The OpenGL implementation may have to hold on to the actual data for much longer after the glDelete…
call; for example there might still be rendering commands in flight that reference objects with names which have been "deleted". The actual cleanup usually happens much later than "your" call of glDelete…
. Also most OpenGL implementations will not actually deallocate memory, but keep it around for recycling with newly created names.
The bottom line is, that with a typical OpenGL implementation Valgrind would report a lot of memory leaks, even if everything is cleanly tidied up on program termination. Hence it's blacklisted.
Upvotes: 6