Skip to content

perf: reduce memory usage by 44 kB - #342392

Merged
Dmitriy Vasyura (dmitrivMS) merged 6 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-emptyPosition
Nov 13, 2026
Merged

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

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Share the match object and highlight array for empty searches so each Command Palette entry no longer keeps its own copy. In a test that opened and closed an editor 17 times, this removed 941 duplicate objects and 941 duplicate arrays, saving 44.1 KiB of renderer memory.


AI disclosure: Model: GPT-6. Worktime: 2 min

Copilot AI balanced review requested due to automatic review settings October 18, 2026 13:35

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.

🟢 Approval recommended

The focused optimization has regression coverage, and no blocking defects were identified.

No open issues 🎉

What changed in this PR

Reduces memory allocations in VS Code’s Command Palette by sharing match results for empty searches.

Changes:

  • Reuses one empty-query match array and object across substring and fuzzy filters.
  • Prevents icon-offset adjustments from mutating shared matches.
  • Adds regression tests for sharing and icon/whitespace handling.
File Description
src/​vs/​base/​test/​common/​iconLabels.test.ts Tests shared matches across icon and whitespace variations.
src/​vs/​base/​test/​common/​filters.test.ts Tests empty-query result sharing across filters.
src/​vs/​base/​common/​iconLabels.ts Skips offset adjustments for shared matches.
src/​vs/​base/​common/​filters.ts Introduces and reuses shared empty-query matches.

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 my comment

@SimonSiefke

Copy link
Copy Markdown
Contributor Author

Done.

@dmitrivMS

Copy link
Copy Markdown
Collaborator
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 6e57ff5 into microsoft:main Nov 13, 2026
52 of 53 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 13, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-emptyPosition branch November 13, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

5 participants