Skip to content

fix: memory leak in auxiliary window font measurements - #338255

Merged
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-fontMeasurements-windowDisposal
Sep 28, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-fontMeasurements-windowDisposal

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Each auxiliary editor window gets its own font-measurement cache. Closing the window leaves that cache and its font readings in the renderer’s global cache map.

Change

Delete the closed window’s cache when the window unregisters. Delayed eviction uses an existing cache instead of recreating one after the window closes.

Before

Moving a text editor to a new window and closing it 37 times grows the font cache map from 3 to 40 entries, adding 37 FontMeasurementsCache, FontInfo, and BareFontInfo objects.

before

After

The font cache map stays at one entry for the live main window. All three font-growth rows disappear; 11 unrelated growth rows remain.

after

Test Video

test.mp4

AI disclosure: Model: GPT-6-Astra (investigation and implementation), GPT-6 (PR preparation). Worktime: approximately 37 min

Copilot AI balanced review requested due to automatic review settings September 27, 2026 19:40

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.

Copilot review overview

🟡 Changes recommended

The delayed-eviction test recreates the cache itself and therefore does not verify the key regression.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes auxiliary-window font measurement caches remaining after window closure.

Changes:

  • Removes caches when windows unregister.
  • Prevents delayed eviction from recreating removed caches.
  • Adds lifecycle and garbage-collection tests.
File Description
src/​vs/​editor/​browser/​config/​fontMeasurements.ts Cleans up per-window caches.
src/​vs/​editor/​test/​browser/​config/​fontMeasurements.test.ts Adds auxiliary-window cleanup tests.

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

Comment thread src/vs/editor/test/browser/config/fontMeasurements.test.ts Outdated
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues workbench-auxwindow Issues related to use of auxiliary ("floating") windows. and removed triage-needed labels Sep 28, 2026
@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 9d4555e into microsoft:main Sep 28, 2026
35 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.141.0 milestone Sep 28, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-fontMeasurements-windowDisposal branch September 29, 2026 11:15
Abdon Morales (abdonmorales) pushed a commit to abdonmorales/vscode-utcs that referenced this pull request Oct 1, 2026
)

* fix: memory leak in auxiliary window font measurements

* test: inspect closed-window font caches without allocating

(cherry picked from commit 9d4555e)
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 workbench-auxwindow Issues related to use of auxiliary ("floating") windows.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants