Repository navigation
fix: memory leak in hidden status bar command arguments - #338238
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The lifecycle fix is focused and its key state transitions are covered by regression tests.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes retained command arguments when hidden status bar items replace commands.
Changes:
- Disposes superseded hidden command registrations.
- Clears stale registrations when hiding.
- Adds command-lifetime regression tests.
| File | Description |
|---|---|
extHostStatusBar.ts |
Corrects command registration cleanup. |
extHostStatusBar.test.ts |
Tests hidden, visible, and disposal lifecycles. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Dmitriy Vasyura (dmitrivMS)
left a comment
There was a problem hiding this comment.
Two lifecycle findings from the independent review, with pinned source links and reproduction sequences below. These are source-derived findings, not live reproductions: the review gate stopped Code OSS and unit-test execution. No runtime retention counts or reproduction frequency were measured. This is a comment-only review, not an approval or request-changes decision.
Dmitriy Vasyura (dmitrivMS)
left a comment
There was a problem hiding this comment.
Possible regression
|
Fixed an issue with in-flight status bar commands, ensuring not to dispose their arguments too early! |
|
Simon Siefke (@SimonSiefke) Thank you! |
Details
Replacing the command of a hidden status bar item puts the previous command registration into a stale-registration store. That store is only cleared by a visible update, so an item that stays hidden accumulates old command arguments.
Change
Dispose superseded command registrations immediately only when they were never published to the renderer. Preserve the last published registration across hiding and hidden replacements, so queued clicks and contributed status bar items that remain visible can still execute their commands. Release published registrations through the existing visible-update or final-disposal cleanup.
Regression tests cover both hide/replacement orderings with delayed command RPCs, contributed entries updated through
DidUpdate, bounded hidden-command retention, showing, and disposal. All 13 targeted status-bar and command tests pass; the new lifetime regressions fail against the original patch.Before
Replacing a hidden status bar command 37 times adds 37 old argument objects and cleanup callbacks. The matching command-cache entries grow from 2 to 39.
After
No more retired-argument or matching callback growth is detected in the same 37-cycle test. The cache stays at one entry for the current command. Small unrelated object-shape differences remain.
Test Video
Seven command replacements while the status bar item remains hidden.
test.mp4
AI disclosure: Model: GPT 6 Astra. Worktime: 24 min