diff --git a/imgui.cpp b/imgui.cpp index c5ce7a1..679bfc7 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1787,11 +1787,13 @@ void* ImGui::MemAlloc(size_t sz) { + GImGui->IO.MetricsAllocs++; return GImGui->IO.MemAllocFn(sz); } void ImGui::MemFree(void* ptr) { + GImGui->IO.MetricsAllocs--; return GImGui->IO.MemFreeFn(ptr); } @@ -11039,6 +11041,7 @@ ImGui::Text("ImGui %s", ImGui::GetVersion()); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); ImGui::Text("%d vertices", ImGui::GetIO().MetricsRenderVertices); + ImGui::Text("%d active allocations", ImGui::GetIO().MetricsAllocs); ImGui::Separator(); struct Funcs diff --git a/imgui.cpp b/imgui.cpp index c5ce7a1..679bfc7 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1787,11 +1787,13 @@ void* ImGui::MemAlloc(size_t sz) { + GImGui->IO.MetricsAllocs++; return GImGui->IO.MemAllocFn(sz); } void ImGui::MemFree(void* ptr) { + GImGui->IO.MetricsAllocs--; return GImGui->IO.MemFreeFn(ptr); } @@ -11039,6 +11041,7 @@ ImGui::Text("ImGui %s", ImGui::GetVersion()); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); ImGui::Text("%d vertices", ImGui::GetIO().MetricsRenderVertices); + ImGui::Text("%d active allocations", ImGui::GetIO().MetricsAllocs); ImGui::Separator(); struct Funcs diff --git a/imgui.h b/imgui.h index 642c02e..f72c4e7 100644 --- a/imgui.h +++ b/imgui.h @@ -696,6 +696,7 @@ bool WantCaptureMouse; // Mouse is hovering a window or widget is active (= ImGui will use your mouse input) bool WantCaptureKeyboard; // Widget is active (= ImGui will use your keyboard input) float Framerate; // Framerate estimation, in frame per second. Rolling average estimation based on IO.DeltaTime over 120 frames + int MetricsAllocs; // Number of active memory allocations int MetricsRenderVertices; // Vertices processed during last call to Render() //------------------------------------------------------------------