Repository navigation
fix: memory leak in SCM repository context keys - #346683
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
Conversation
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Ladislau Szomoru (@lszomoru)Matched files:
|
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the SCM repository visibility context-key cleanup.
No open issues 🎉
What changed in this PR
This PR fixes memory retention in SCM repository visibility context keys by preventing repository-specific names from remaining in global metadata and removing context entries when reset.
Changes:
- Disable metadata registration and use an undefined default for repository visibility keys.
- Add regression tests for metadata exclusion, reset cleanup, and active repository visibility expressions.
| File | Description |
|---|---|
src/vs/workbench/contrib/scm/test/browser/scmRepositoryVisibility.test.ts |
Tests metadata exclusion, key cleanup, and visibility expressions. |
src/vs/workbench/contrib/scm/browser/scmViewPane.ts |
Updates visibility key defaults and disables global metadata registration. |
Review effort: Balanced
Dmitriy Vasyura (dmitrivMS)
left a comment
There was a problem hiding this comment.
Please consider CCR feedback.
|
[ai-response] Addressed the Copilot test feedback in c4b76a0: the reset regression now checks actual key removal from the context's own values, including a positive presence check before reset. The SCM visibility and ContextKeyService suites, targeted lint and hygiene pass locally. A compiled-output mutation that retains the key with |
|
Added some minor test change. |
|
Simon Siefke (@SimonSiefke) Thank you! |
3543807
into
microsoft:main

Details
Creating a repository visibility key registers its repository-specific name in global context-key metadata. When the repository closes, reset keeps a false entry in the context, and both indexes keep those names.
Change
Skip metadata registration for repository-specific visibility keys and use an undefined default so reset removes the context entry.
Before
Three fresh-profile renderer trials, each with two warmup cycles and 17 measured repository close/reopen cycles, count only per-repository
scmRepositoryVisible:scm…string objects. Both heap snapshots follow garbage collection; the charts show growth in shallow string bytes.Every trial adds 17 strings (680 bytes), growing from 3 strings (120 bytes) to 20 strings (800 bytes). Heap paths lead to
RawContextKey._infoand context entries for closed repositories.After
All three trials stay at 1 string (40 bytes), with 0 strings and 0 bytes of growth. The remaining key belongs to the active repository. Global metadata contains none of these keys, and closed-repository context entries are removed.
Test Video
scm-repository-context-native.webm
AI disclosure: Model: GPT 6.1 Sol. Worktime: 20 min