Skip to content

fix: memory leak in code actions - #330142

Merged
Dmitriy Vasyura (dmitrivMS) merged 10 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-quick-fix
Aug 13, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 10 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-quick-fix

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

CodeActionModel.trigger() permanently disposed its reusable MutableDisposable before the asynchronous CodeActionSet was assigned. The later assignment became a no-op, so closing the editor never disposed the set and its extension-host command payloads remained cached.

Change

Clear the holder when triggering new code actions so it remains reusable, and clear the current code-action set when the editor model changes.

Before

When applying a TypeScript quick fix and closing the editor 37 times, VsCodeCodeAction, workspace edits, diagnostics, and closed-document functions each grow by 37, while related code-action objects grow faster:

editor-autofixes-available before

After

No matching code-action or closed-document leak is detected.

Test Video

editor-autofixes-available.after.webm

Copilot AI balanced review requested due to automatic review settings August 10, 2026 23:44

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.

Pull request overview

Fixes code-action payload leaks by keeping the reusable disposable holder active and clearing stale action sets.

Changes:

  • Clear retained code actions on retrigger and editor-model changes.
  • Add regression coverage verifying disposal after clearing the model.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/vs/editor/contrib/codeAction/browser/codeActionModel.ts Corrects code-action disposal lifecycle.
src/vs/editor/contrib/codeAction/test/browser/codeActionModel.test.ts Tests disposal of manually triggered actions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 507a5a0 into microsoft:main Aug 13, 2026
27 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.134.0 milestone Aug 13, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-quick-fix branch August 13, 2026 20:14
@DanTup

Danny Tuppeny (DanTup) commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

FYI - this PR might have introduced a bug where code actions that trigger commands with args are invoked more than a few seconds after opening the editor show an error:

See #331834

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants