Skip to content
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

multi-viewport memory leaks #4504

Closed
straywriter opened this issue Sep 3, 2021 · 6 comments
Closed

multi-viewport memory leaks #4504

straywriter opened this issue Sep 3, 2021 · 6 comments

Comments

@straywriter
Copy link

straywriter commented Sep 3, 2021

Version/Branch of Dear ImGui:

Version: dear imgui, v1.84 WIP
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: Visual Studio 2019
Operating System: Windows 10

My Issue/Question:

This example has memory leak in multi-viewport case, how to fix
I didn't change any code
This does not seem to be the case with the other examples

My GPU:
GeForce GTX 1050 Ti
Version:457.49

Screenshots/Video

image

Memory leaks when the example moves out of the window
aa

When the window is moved back, memory is restored
bb

@ocornut
Copy link
Owner

ocornut commented Sep 3, 2021

Three issues below yours this one is listed: #4468. Moving there…
Can you confirm if the workaround discussed in #4468 fixes it for you?

@ocornut
Copy link
Owner

ocornut commented Sep 3, 2021

Please also provide details about GPU and Drivers version. And after testing if the changes discussed in the other are fixing the issue for you, you can also try updating drivers and see if it works without the changes.

@straywriter
Copy link
Author

Thank you. I will do some work according to relevant content and get back to you after completion

@straywriter
Copy link
Author

straywriter commented Sep 3, 2021

@ocornut
hi,I found a way to solve this problem。
I have done some debugging work, but I still haven't found the specific cause. It may be the cause of OpengL or the incompatibility between GLFW creation window and OpengL. However, I haven't tested the CASE of SDL, so I'm not sure.
However, I found that the main problem occurred here:

static void ImGui_ImplOpenGL3_InitPlatformInterface()
{
    ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
    platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL3_RenderWindow;
}

I took advantage of OpengL's backward compatibility features to solve this problem for the time being. This solution may not seem perfect, but at least it will keep memory from leaking.
Porting opengL2 ImGui_ImplOpenGL2_RenderWindow to opengl3 can solve the problem effectively.

static void ImGui_ImplOpenGL2_InitPlatformInterface()
{
    ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
    platform_io.Renderer_RenderWindow = ImGui_ImplOpenGL2_RenderWindow;
}

What do you think about that

cc

@ocornut
Copy link
Owner

ocornut commented Sep 3, 2021

Hello @straywriter,

Please post in #4468 and try the change mentioned here:
#4468 (comment)

There is a features/opengl_buffer_update branch of the repository you can test.

@ocornut
Copy link
Owner

ocornut commented Nov 9, 2022

Reverted the changes of #4468 with b8b0f9d, not using glBufferSubData() anymore.
PLEASE REPORT IF YOU STILL HAVE ISSUES AFTER TODAY.
I temporarily kept the alternative code path even though bd->UseBufferSubData is always false, allowing potential experiment shall new issues arises. Finger crossed this doesn't bite us back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants