Repository navigation
fix: memory leak in emitter warning names - #347966
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits intoNov 13, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The test still passes with the original eager allocation, so it needs an assertion before listeners are added that unnamed emitters do not retain a generated _leakWarningName.
1 open issue
What changed in this PR
This PR reduces retained diagnostic strings in VS Code’s event emitters by deferring automatic warning-name generation until a leakage monitor is created.
Changes:
- Removes eager automatic name allocation while preserving custom names and captured warning configuration.
- Allows unnamed emitters to use the leakage monitor’s default name generation.
- Adds a test for stable, distinct names in listener-leak warnings.
| File | Description |
|---|---|
src/vs/base/test/common/event.test.ts |
Tests generated warning-name stability and uniqueness across emitters. |
src/vs/base/common/event.ts |
Defers automatic naming until leakage monitor creation. |
Review effort: Balanced
Collaborator
|
Simon Siefke (@SimonSiefke) Thank you! |
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
November 13, 2026 02:43
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 13, 2026
Justin Chen (justschen)
approved these changes
Nov 13, 2026
Anthony Kim (anthonykim1)
approved these changes
Nov 13, 2026
Dmitriy Vasyura (dmitrivMS)
merged commit Nov 13, 2026
2c4376d
into
microsoft:main
52 of 53 checks passed
Simon Siefke (SimonSiefke)
deleted the
fix/memory-leak-emitter-warning-names
branch
November 13, 2026 10:07
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
With workbench listener-leak warnings enabled, each emitter stores an automatically generated name even when it never needs a leakage monitor. Rebuilding Settings leaves thousands of these unused diagnostic strings in live emitters.
Change
Generate an automatic name only when creating the leakage monitor, using its existing constructor default. Preserve custom names, warning thresholds, and error handlers.
Before
When opening, splitting, and closing Settings 17 times, 5,657 emitters hold unused generated names occupying 99,064 bytes. Total string growth is 3,183,640 bytes and 21,532 strings.
After
Both snapshots contain zero unused generated emitter names. Total string growth is 3,107,216 bytes and 18,298 strings; other Settings allocations remain.
Test Video
emitter-warning-names-native.webm
AI disclosure: Model: GPT 6.1 Sol. Worktime: 25 min