Skip to content

Fixes issue with g_ContextMap outliving zgui#88

Merged
hazeycode merged 1 commit intozig-gamedev:mainfrom
simeks:glfw-backend-fix
Mar 5, 2026
Merged

Fixes issue with g_ContextMap outliving zgui#88
hazeycode merged 1 commit intozig-gamedev:mainfrom
simeks:glfw-backend-fix

Conversation

@simeks
Copy link
Copy Markdown
Contributor

@simeks simeks commented Jan 8, 2026

Not sure this is the way to go but this fixes #79 (and potentially #80).

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a shutdown-time allocation lifetime problem in the vendored Dear ImGui GLFW backend where the static g_ContextMap can retain heap memory until process exit, causing leak reports (and, in shared-library scenarios, potential invalid MemFree calls after zgui is deinitialized).

Changes:

  • Free g_ContextMap’s backing storage during ImGui_ImplGlfw_Shutdown() when the map becomes empty, preventing late (atexit) frees.
  • Add an explanatory comment describing why the eager free is necessary in this integration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zig-gamedev zig-gamedev deleted a comment from Copilot AI Mar 5, 2026
@hazeycode hazeycode merged commit b6a4dff into zig-gamedev:main Mar 5, 2026
7 checks passed
@hazeycode
Copy link
Copy Markdown
Member

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unknown memory leakage.

3 participants