-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Textures are leaked on context shutdown #133
Comments
To elaborate, this is how i tried to shut down RmlUi and it was leaking textures: delete Rml::GetRenderInterface();
delete Rml::GetSystemInterface();
delete Rml::GetFileInterface();
Rml::ReleaseTextures();
Rml::Shutdown(); When we delete This works: Rml::ReleaseTextures();
delete Rml::GetRenderInterface();
delete Rml::GetSystemInterface();
delete Rml::GetFileInterface();
Rml::Shutdown(); Do we have some documentation detailing shutdown procedure that i missed? This really has to be documented as it is very not straightforward. Maybe even documented above |
The interfaces must stay alive until after the call to This would be the correct order for you:
I've tried to document the lifetime requirements several places. Perhaps they could be more strongly worded, I'm all ears on suggestions on how to improve the documentation (or pull requests). |
Right, i missed those, my fault :) But in that case void TextureDatabase::Shutdown()
{
delete texture_database;
} Which would eventually call |
Yeah, there seems to be an issue here that generated textures are not released. These textures are not owned by the texture database, but rather (in case of font textures) by the font engine. There is a broader issue here as well that font textures aren't released when they are no longer in use, we should have some functionality for garbage collecting them. It does make sense to call I'll try to come up with some solutions, in the meantime we can call We might as well put some asserts on the interface pointers, but I'm guessing most will just leave them hanging. We could also employ |
…hutdown calls. Log an error in debug mode if any textures leak after shutdown. See #133.
Alright, there was actually an issue here with the internal shutdown order. Some reordering and the font textures should now be released during shutdown. There could potentially be other generated textures hanging around, so I added a log error in debug mode to look for any leaking textures. Let me know if you ever encounter this :) Btw, my code in the post above will not work, because There is still the issue of garbage collecting font textures, but that is probably more suitable to discuss in another issue. |
I think, some trouble is caused by TextureDatabase::ReleaseTextures(this) in the destructor because it calls the virtual member function ReleaseTextures, but the override implementation is not called if it called from a destructor, so the empty function in the RenderInterface is called, and the texture is leaked. My current workaround is to call TextureDatabase::ReleaseTextures(this) from the RenderInterface implementation class destructor. But not sure if this workaround is a correct c++ standard behavior. Anyway TextureDatabase.h is also not a public interface of RmlUI. My fast google search for virtual function destructors issues: Should made this a separate bug? |
I was a bit confused at first, but I see the issue now: So indeed, this is problematic. However, this is really only a problem if the render interface is destroyed before the call to My suggestion is to just remove this call entirely from the destructor, as I don't see the point of it. Yes, I'd prefer to continue the discussion in a new issue, thanks! |
I have multiple calls to
GenerateTexture()
of renderer interface, butReleaseTexture()
is never called, even when RmlUI is shut down. Even if i callRml::ReleaseTextures()
beforeRml::Shutdown()
.The text was updated successfully, but these errors were encountered: