fix: memory leak in suggest enabled input by SimonSiefke · Pull Request #340913 · microsoft/vscode · GitHub
Skip to content

fix: memory leak in suggest enabled input - #340913

Merged
Dmitriy Vasyura (dmitrivMS) merged 8 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-suggestEnabledInput
Oct 14, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 8 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-suggestEnabledInput

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

SuggestEnabledInput gives each embedded editor a unique synthetic model URI and registers a completion provider with a **/<path> selector. Language-selector scoring compiles each unique path through the global glob cache.

The Settings Editor lifecycle test opens, searches, switches scopes, and closes the editor 37 times. It produced 37 new isEqualOrParent closures, 37 parsedPattern closures, and 37 copies of each of the two anonymous option closures. Heap paths end in the glob cache with keys such as default:**/searchinput12_false_false.

Change

Register the provider for the synthetic URI scheme and reject models whose URI does not exactly match the input model. This preserves completion behavior for the intended input without creating a per-input glob cache entry. A browser test checks both the matching input model and another model with the same scheme.

Before

After 37 Settings Editor lifecycle cycles, all four glob-related closure families grew by 37.

before

After

The four glob-related rows are absent after the same 37 cycles. The remaining ScopedMemento row comes from independent modal-editor memento growth and is being handled separately.

after

Test Video

The video shows three candidate cycles opening Settings, searching, switching between Workspace and User scopes, and closing the editor.

settings-editor-lifecycle.webm

Copilot AI balanced review requested due to automatic review settings October 11, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Scheme-less Keybindings Editor inputs lose completion support under the new selector.

1 open finding
What changed in this PR

Removes per-input glob selectors from SuggestEnabledInput to prevent glob-cache memory growth.

Changes:

  • Registers completion providers by URI scheme and validates exact model URIs.
  • Adds coverage for matching and nonmatching resources.
File Description
suggestEnabledInput.ts Replaces glob-based provider selection.
suggestEnabledInput.test.ts Tests exact-resource completion behavior.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The scheme-only selector unintentionally registers Keybindings input trigger characters for every file editor.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider review comment

@SimonSiefke

Copy link
Copy Markdown
Contributor Author

Addressed feedback. I don't think that can apply in practice.

@dmitrivMS

Copy link
Copy Markdown
Collaborator

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit e07973c into microsoft:main Oct 14, 2026
35 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues suggest IntelliSense, Auto Complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants