Skip to content

Fix: Resolved memory growth from native resources and Linux window placement#72

Open
malumar wants to merge 3 commits into
richardwilkes:mainfrom
malumar:fix-memory-leak
Open

Fix: Resolved memory growth from native resources and Linux window placement#72
malumar wants to merge 3 commits into
richardwilkes:mainfrom
malumar:fix-memory-leak

Conversation

@malumar
Copy link
Copy Markdown

@malumar malumar commented Apr 10, 2026

Hi Richard,

I’ve been exploring Unison and I’m really impressed with the project! However, I’ve noticed a significant memory leak when running example applications on Linux.

1. Resolved Memory Growth during Redraw

I identified and fixed a steady increase in RAM usage caused by high-frequency creation of native Skia-backed objects.

  • Problem: Paint, Path, Shader, and TextBlob wrappers were not being released fast enough by the Go GC.
  • Solution: I implemented a deterministic per-frame cleanup. Temporary resources are now registered in Canvas and explicitly disposed of immediately after Flush().

2. Fixed Linux Window Placement

Addressed an issue where decorated windows (specifically on Fedora KDE) were positioned incorrectly.

  • Fix: Corrected the frame extent calculation logic (switching from subtraction to summation of edge thicknesses).
  • Fallback: Added a robust fallback for environments where GLFW/Compositor reports zero decoration metrics for decorated windows.
  • Test Tool: Included a small utility at cmd/windowbar/main.go to verify correct title-bar placement.

I've documented the technical details and the list of affected files in the changes.md file included in this PR.

All tests passed on my end, and memory usage is now stable during heavy redraws (e.g., indeterminate ProgressBar).

malumar added 3 commits April 10, 2026 13:07
… Linux window frame placement for unreliable

window decoration metrics.

Add deterministic per-frame cleanup for transient Skia-backed objects ( Paint ,  Path ,  Shader ,  TextBlob ),
which previously caused ongoing memory growth during  ProgressBar  indeterminate animation and normal application
use. Also fix frame extent math and add Linux window-decoration fallbacks for environments such as KDE (Fedora)
where GLFW may report decoration sizes incorrectly or not at all.
decoration sizes incorrectly or not at all.
@richardwilkes
Copy link
Copy Markdown
Owner

Thanks for the PR. I'll take a look when I get some spare time (in very short supply lately, due to a series of family emergencies this year).

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.

2 participants