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

ImGui_ImplAllegro5_UpdateMouseCursor should not create a new cursor each frame #8256

Closed
wants to merge 1 commit into from

Conversation

Helodity
Copy link
Contributor

Currently, ImGui sends a call to Allegro each time a frame is drawn, either reusing a stored invisible cursor or creating a new system cursor.

Allegro currently has a memory leak in its X11 interface (see this Allegro PR) where system cursors are not cleared when a new one is generated. This paired with creating a new cursor each frame results in a leak that results in an XWayland abort within 10 minutes (see this xorg bug report)

This fix reduces the amount of unnecessary cursor creations by caching which cursor is currently being rendered, and only creating a new one when it changes. This does not fix the memory leak, but heavily mitigates its effect.

ocornut pushed a commit that referenced this pull request Jan 6, 2025
@ocornut
Copy link
Owner

ocornut commented Jan 6, 2025

Thank you for the PR.
Indeed it doesn't seem like there is a way to call the equivalent of al_create_mouse_cursor for a system cursor so I cannot think of another workaround, it would be work reporting to Allegro repository.

I reworked and pushed your fix as 2d2c7d3 (fixed the coding-style to match what's in the file).

Thanks!

@ocornut ocornut closed this Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants