Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions crates/lspkit-server/src/live/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,21 @@ mod tests {
assert!(output.is_closed());
assert!(source.send(Ok(Event::new(EventKind::Other))).is_err());
}

/// The forwarder thread is spawned unowned, so it must end with its
/// owner: dropping the native watcher closes its event channel, the thread
/// exits and releases the sender, and the stream ends.
#[tokio::test]
async fn dropping_the_native_watcher_ends_the_forwarder_thread() {
let root = tempfile::tempdir().expect("watched root");
let super::FileWatcher {
_inner: native,
mut rx,
} = super::FileWatcher::new(root.path()).expect("watch the root");
drop(native);
assert!(
rx.recv().await.is_none(),
"the forwarder thread outlived the native watcher"
);
}
}
4 changes: 2 additions & 2 deletions docs/plans/memory-leak-fixes-0.6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Fix every leak in the v0.6.0 static review (four pi agents on GLM 5.3 plus a man
## [MEM-060-NOT-LEAKS] Checked and left as they are

- **M9 `Symbolizer` `_ids`:** each CPU session runs its own engine process, and the interner is that recording's frame dictionary, mirrored by the Rust relay. It goes when the session's engine exits.
- **Other unowned handles (`live/scheduler.rs`, `live/watcher.rs`, `cooperative.rs`):** each ends with its consumer. The scheduler task selects on its consumer's `closed()` (tested); the watcher thread exits when its receiver or native watcher drops; the cooperative tail thread exits at its header deadline or when its sink is dropped.
- **`forgotten` close queue:** a `HashSet` of URIs, bounded by distinct closed documents and drained by the query that holds the state once it finishes.
- **Other unowned handles (`live/scheduler.rs`, `live/watcher.rs`, `cooperative.rs`):** each ends with its consumer. The scheduler task selects on its consumer's `closed()` (tested); the watcher thread (pinned by `dropping_the_native_watcher_ends_the_forwarder_thread`) exits when its receiver or native watcher drops; the cooperative tail thread exits at its header deadline or when its sink is dropped.
- **`forgotten` close queue:** a `HashSet` of URIs, bounded by distinct closed documents and drained by the query that holds the state once it finishes (`pull_forget.rs::forget_returns_while_a_compiler_query_runs_and_the_next_pull_applies_it`).
- **Decoration-type maps:** keyed by palette colours (a handful of heat and confidence levels) and disposed on deactivate.
- **Sidecar responses and the example's response frames:** bounded by the requests in flight. Dropping a response would break the protocol.
- **One analysis per trigger:** `Session::run` keeps its tested contract (`run_advances_generation_on_each_success`). The scheduler adds no memory: each event lands in exactly one trigger.
Expand Down
Loading