Repository navigation
fix: memory leak in pixel ratio window disposal - #338257
Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits intoSep 28, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 2 commits into
Dmitriy Vasyura (dmitrivMS) merged 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The primary regression tests are skipped during normal CI because exposed garbage collection is unavailable.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Fixes pixel-ratio monitor cleanup when unrelated auxiliary windows close first.
Changes:
- Retains unregister listeners until their matching window closes.
- Adds regression tests for multi-window disposal ordering.
| File | Description |
|---|---|
src/vs/base/browser/pixelRatio.ts |
Corrects monitor disposal lifecycle. |
src/vs/base/test/browser/pixelRatio.test.ts |
Adds lifecycle regression tests. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Dmitriy Vasyura (dmitrivMS)
approved these changes
Sep 28, 2026
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
September 28, 2026 06:37
Collaborator
|
Simon Siefke (@SimonSiefke) Thank you! |
Christof Marti (chrmarti)
approved these changes
Sep 28, 2026
Ladislau Szomoru (lszomoru)
approved these changes
Sep 28, 2026
Dmitriy Vasyura (dmitrivMS)
merged commit Sep 28, 2026
4485486
into
microsoft:main
36 of 38 checks passed
Simon Siefke (SimonSiefke)
deleted the
fix/memory-leak-pixelRatio-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: release pixel ratio monitors when their window closes * test: verify pixel ratio cleanup without explicit GC (cherry picked from commit 4485486)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Details
A pixel-ratio monitor listens once for any window to close, then checks the window ID. If another window closes first, that consumes the listener, leaving the monitor and its window in the global monitor map when its own window closes.
Change
Keep the unregister listener until its own window closes, then dispose the listener and monitor and remove the map entry.
Before
Opening two auxiliary editor windows, closing the first, and then closing the second 37 times grows the monitor map from 3 to 40 entries. PixelRatioMonitorImpl, DevicePixelRatioMonitor, and NativeAuxiliaryWindow each grow by 37.
After
The monitor map stays at one entry for the live main window. Pixel-ratio monitors and NativeAuxiliaryWindow no longer grow; 15 unrelated growth rows remain, including font caches and menu actions.
Test Video
test.mp4
AI disclosure: Model: GPT-6-Astra (investigation and implementation), GPT-6 (PR preparation). Worktime: approximately 51 min