Description
Version
1.89.0 (new) and 1.86.12 (old)
What happened?
A bug happened!
I am not sure how this bug occurs, and I haven't been able to identify a consistent pattern for its appearance. The issue manifests as a rapid increase in the number of “java.nio.DirectIntBufferU” objects after building the UI in a certain way, eventually leading to a memory leak.
I have observed this bug in multiple versions. I first discovered it accidentally while using version 1.86.12. Later, I upgraded to 1.89.0 and switched to using imgui-app as the windowing platform for testing, but the bug still occurred.
This bug does not cause any exceptions or crashes, but it leads to a continuous and significant increase in memory usage. I directly copied the initial test code recommended on the imgui-java homepage, and then added 6 windows along with several ImGui.text calls. I noticed that this bug only occurs when these windows and text calls are arranged in a certain specific pattern. For example, if I remove the last window (Window 6), the bug disappears. Therefore, I cannot summarize a consistent pattern that triggers the bug.
Reproduction
import imgui.ImGui;
import imgui.app.Application;
import imgui.app.Configuration;
// From the home page of imgui-java
public class Main extends Application {
@Override
protected void configure(Configuration config) {
config.setTitle("Dear ImGui is Awesome!");
}
@Override
public void process() {
// window 1
imgui.internal.ImGui.begin("a1");
// end
imgui.ImGui.end();
// window 2
if (imgui.internal.ImGui.begin("a2")) {
imgui.internal.ImGui.text("1");
}
// end
imgui.ImGui.end();
// window 3
if (imgui.internal.ImGui.begin("a3")) {
imgui.internal.ImGui.text("2");
}
// end
imgui.ImGui.end();
// window 4
if (imgui.internal.ImGui.begin("a4")) {
imgui.internal.ImGui.text("3");
}
// end
imgui.ImGui.end();
// window 5
imgui.internal.ImGui.begin("a5");
// end
imgui.ImGui.end();
// window 6
imgui.internal.ImGui.begin("a6");
// end
imgui.ImGui.end();
}
public static void main(String[] args) {
launch(new Main());
}
}
Relevant log output
// No error but memory leak.
// Object Type : "java.nio.DirectIntBufferU"
// Tool : Jprofiler , IDEA