ice1000 / jimgui

:sparkling_heart: Pure Java binding for dear-imgui
Apache License 2.0
185 stars 13 forks source link

Memory leaks #66

Closed newk5 closed 3 years ago

newk5 commented 3 years ago

I found memory leaks using the following functions:

ice1000 commented 3 years ago

It'll be appreciated if you could post some snippets for testing and verification

newk5 commented 3 years ago
 JniLoader.load();
 try (JImGui imgui = new JImGui()) {
     byte[] b = new byte[100];

     imgui.initBeforeMainLoop();
     while (!imgui.windowShouldClose()) {

             imgui.initNewFrame();

            for (int i = 0; i < 50; i++) {

                 imgui.inputText("", b);
            }

            imgui.render();

     }
 }

You can change the code above to inputInt/Float/Double and the same issue will happen.

You can also add imgui.pushID before creating the inputs and imgui.popID after to reproduce the leak with push/pop ID

ice1000 commented 3 years ago

Tbh, I don't see why they're leaking...

ice1000 commented 3 years ago

https://youtu.be/Yu04nU5rPO8

newk5 commented 3 years ago

After further tests I can conclude this is happening everywhere where String is used instead of JImStr

ice1000 commented 3 years ago

Then I'll consider this as a duplicate of #35

newk5 commented 3 years ago

Yea I guess this isn't a leak, it's just overhead from java strings being converted.