-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Memory leak (and crash) in ImGui_ImplAndroid_Shutdown()
#1915
Comments
The ImGui implementation for Android was a test implementation to try and see if ImGui would work on that platform, since it was previously limited to desktop (Windows/OpenGL). The input handling in the Android implementation of ImGui may also not be working correctly, so there is little point in using it on that platform for the time being. It would be best to disable ImGui if you're building a project (including cpp-tests) for Android, at least until all these issues with the Android ImGui implementation are addressed. |
@rh101 |
@halx99 |
Out of curiosity, for what reason are you running the Auto Test function? If you're new to Axmol, and you're looking to learn more about it, then just be aware that the Auto Test is not for that purpose. |
I was just tryin' make sure that everything works absolutely fine. I was playing with cocos2d this morning and found that it sucks... dependency hell. That's when I somehow spotted Axmol in some issue in their repository. |
PR #1920 will fix the ImGui crash on Android, but as for the possible memory leak, that will require more investigation. |
The pointer is an instance of The only object that is retained is the |
Yeah I see, but as far as I knows what |
The
Autorelease doesn't actually have anything to do with this, and there may be some misunderstanding as to what its purpose is. Just in case, we do have a wiki article explaining the reference counting model used in Axmol, along with a section on autorelease, which you can find here. |
Steps to Reproduce:
CppTests
projectI'm completely new to developing with Axmol (and any sort of game development in general), so forgive me if I made technical mistakes. I have also searched the whole Axmol repo and omar's ImGui repo as well, so apologies if this issue was a duplicate.
I've been trying to get Axmol and Android Studio working this afternoon, and when I compile the
CppTests
project, I notice that the app crashes immediately if I try to conduct an Autotest, or when I leave the ImGui tests. Everything else works just fine. When I look at the logs, I notice that an assertion fromImGui::Shutdown()
,ASSERT_USER_ERROR(g.IO.BackendRendererUserData == NULL)
failed. I was able to locate the code which guarantees that the other assertion is good, inImGui_ImplAndroid_Shutdown()
.To my surprise, the way that this piece of code does resource de-allocation astonishes me: it simply sets pointers from
struct ImGuiIO
toNULL
. This is, to my knowledge, not in accordance with standard C++ coding practices to the very least. By removing the assertion inImGui::Shutdown
and watching the memory in LLDB, I was able to prove that the contents that the pointer points to retains their lifecycle for a long time after the ImGui Scene has been destroyed. This was further proved by settingAX_REF_LEAK_DETECTION
as 1 and printing the leaked objects. By repeatingImGuiTest()
in an infinite loop, I observed ~2 MiB memory leaked in about 30 minutes, loosely corresponding to about 100 bytes, or an ImGui frame leaked every second.I admit that this may not be a major issue, but hopes that it may get fixed soon. At least the app should not crash on destroying the ImGui Scene, that would make games (which require extensive configuration) based on Axmol impossible to play.
The text was updated successfully, but these errors were encountered: