Login  Register

GLContextShareSet leaks GLContexts (?)

Posted by Ivan on Dec 02, 2016; 3:44pm
URL: https://forum.jogamp.org/GLContextShareSet-leaks-GLContexts-tp4037493.html

Hello,

We came across what looks like a potential leak of GLContexts in the class jogamp.opengl.GLContextShareSet.

Whenever we create a context that is linked to a master context we have here is what happen:
-> GLContextShareSet#addNew
--> Adds the new context in destroyedShares Map
-> GLContextShareSet#contextCreated
--> Removes the new context from destroyedShares Map
--> Adds the new context to createdShares Map

Then when we close the corresponding window it tries to destroy the context
-> GLContextShareSet#contextDestroyed
--> Removes the context from createdShares Map
--> Adds the context to destroyedShares Map

So at the end of the day, the context is still referenced by the destroyedShares Map.

And it gets stranger when I look at the code, as there is no way to actually remove a context from destroyedShares Map. The only place where #remove() is called on destroyedShares is in contextCreated, which adds the context to the createdShares Map.