Repository navigation
fix(foreground): close the process handle after reading the exe name - #1
Merged
Merged
Conversation
The foreground watcher opened the focused window's process with OpenProcess every 750 ms and never closed the handle. Over 20 days of uptime the app held 1.28 million process handles, growing by about 1.3 per second. The handle now lives in a guard that closes it on every path, including when QueryFullProcessImageNameW fails.
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.
The foreground watcher (
app/src-tauri/src/foreground.rs) callsOpenProcessfor the focused window's process every 750 ms to read its exe name, but never closed the handle.On a PC with 20 days of uptime the app held 1,285,805 handles, 99.97 % of them process handles, growing by about 1.3 per second.
Fix: the handle is wrapped in a small guard that calls
CloseHandleon drop, so it is released on every path, including the early return whenQueryFullProcessImageNameWfails.Verified: a local release build ran for 90 s while the foreground window changed. The handle count stayed at about 350 (the old build gained about 126 in the same time).
cargo fmt --checkandcargo clippyfor the app crate report no new warnings.