Repository navigation
fix: memory leak in menu hidden defaults - #348413
Open
Simon Siefke (SimonSiefke) wants to merge 3 commits into
Open
Simon Siefke (SimonSiefke) wants to merge 3 commits into
Simon Siefke (SimonSiefke) wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the menu-service change to reduce retained cache entries.
No open issues 🎉
What changed in this PR
This PR reduces memory retention in the menu service by removing redundant visible-default cache entries, so disposed dynamic commands no longer leave those keys behind.
Changes:
- Cache only hidden (
true) defaults and delete entries for visible (false) defaults. - Add regression tests for default changes, user overrides, disposed registrations, and replacement registrations.
No actionable findings remain. Tests were not run during this review.
| File | Description |
|---|---|
src/vs/platform/actions/test/common/menuService.test.ts |
Adds coverage for cache retention and hidden-state behavior. |
src/vs/platform/actions/common/menuService.ts |
Deletes false-default entries instead of retaining them. |
Review effort: Balanced
This branch has not been deployed
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
The menu service caches false defaults under combined menu and command IDs. The cache outlives dynamic command registrations and keeps their key strings after the commands are disposed.
Change
Store only true hidden defaults and delete false entries, since a missing entry already means false.
Before
When registering commands, opening the Command Palette, and disposing the commands 17 times, the cache holds 1,052 redundant false entries. These include 17 disposed-command keys occupying 1,020 bytes. Total string growth is 200,784 bytes and 5,056 strings.
After
The cache has zero visible-default entries, including zero disposed-command keys. Total string growth is 155,664 bytes and 4,380 strings; other UI allocations remain.
Test Video
menu-hidden-defaults-native.webm
AI disclosure: Model: GPT 6.1 Sol. Worktime: 15 min