-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Multiple Contexts shutdown leak or not clear #1558
Comments
Thank you for the detailed post. There are several issues related to this (#591, #1007, #586, #992). I don't have the exact answer right now but those issues have been lingering and I will try to tackle some of them soon. Also note that I am working on a new system to use a single imgui context for multiple windows (see #1542). If you are not looking for multi-threading or rendering at different frequency, using that new system will be much better :) |
- YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END. - removed Shutdown() function, as DestroyContext() serve this purpose. - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwhise CreateContext() will create its own font atlas instance. - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts. - removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts (#1565, #586, #992, #1007, #1558)
Hello, I am using imgui and my app has multiple windows.
The version used is one year old but the weird problem is still present in last version.
I used as recommended since there the use of multiple context, one by windows.
I hooked our memory management system on Alloc & Free callbacks and it seems there was some leaks.
At first my code was looking like that:
I found that each allocation by context was not freed, so I changed my code in this :
But it crashed because It seems that I use a single Font which is shared between context.
So now everything is working (no leak anymore) with this change:
ImGui::SetCurrentContext(wContext); + ImGui::GetIO().Fonts = null; ImGui::Shutdown();
But this looks so unexpected and not documented in comments. I'm not sure this is the way it should be uninitialized, so I prefer to refer my code here to know what it is the real purpose of
Shutdown()
andDestroyContext()
. The destructor~ImGuiContext
doesn't exist but is explicitly called inDestroyContext()
.Please let me know what you think about this case.
The text was updated successfully, but these errors were encountered: