Repository navigation
fix: snapr no longer builds up memory the longer it runs - #20
Merged
Merged
Conversation
A council review (Fable, Neon, Sol 6.1) of everything that adds to memory in the long-running tray process turned up these: - Recent: each large preview (up to 1920x1200, ~9 MB) stayed cached for as long as the window was open, as did the thumbnails of items that fell off the 200-item list, and loads finishing after their item was removed were put back. Only the shown preview is kept now, thumbnails go with their items, and stale loads are dropped. - Windows that close (capture overlays, pins, the toast) left their last frames' GPU textures, a frozen screen per monitor, until the next window drew: wgpu only frees them when it checks on submitted work. snapr now has it check once a window has closed. - Recording: a sound source that ended early (pw-record exiting, say) stopped padding silence, so the mixer, which mixes only what every source has delivered, held the others' samples for the rest of the recording (~384 KB/s). It stays silent until the end instead. - Recording on X11, GNOME/KDE Wayland and macOS: frames that arrived just before stopping stayed queued with the cached recorder until the next recording on that monitor. They're dropped on stopping. - FFmpeg recordings with sound left their raw audio (~23 MB a minute) in the temp folder. - macOS: decoding a video in the thumbnail thread, which has no run loop, left its asset and reader in an autorelease pool until the window closed. The whole read now runs in its own pool. - macOS and Linux: open/xdg-open, run to open files, links and folders, stayed as zombie processes. They're waited for now. - Linux portal hotkeys: a session whose shortcuts were refused or cancelled stayed open in the portal; it's closed.
From the council's second round: - Count the windows by kind: a capture that ends in a pin opens the pin before the capture's windows close, so the total didn't drop and the frozen screens stayed. - Check last in `about_to_wait`, after the toast may have timed out there; on Linux nothing else wakes the loop once it has gone. - wgpu panics on poll errors other than a timeout (a lost device, say), where drawing only fails quietly. Don't let that take the tray down.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
snapr lives in the tray for days, so anything that grows with each capture, recording or click adds up. A review of everything that adds to memory found eight places where that happened. The worst was the Recent page: every preview you looked at stayed in memory, up to about 9 MB each, for as long as the window was open.
What leaked, and the fix
pw-recordexiting, say), the other's audio piled up at about 384 KB a second until you stopped. The stopped source now counts as silence until the end. A new test covers this.open/xdg-openused to open files, links and folders stayed behind as a zombie process. They're now waited for.Not changed, on purpose
None of these grow with use, so I left them out of this PR:
Testing
cargo check,cargo +1.99.1 clippy --all-targets -D warningsandcargo test(189 passed) all pass locally.cargo check --all-targetspasses in WSL Ubuntu.Council review
Rounds: 3
Round 1 scored the app's existing memory hygiene. Rounds 2 and 3 scored this change.