Skip to content

fix: memory leak in color picker - #345461

Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-colorPicker
Nov 4, 2026
Merged

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

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Each color picker drag adds a new pointer monitor to the control's disposable store. Ending the drag stops the monitor but does not remove it from the store, so repeated drags keep adding monitors until the color picker closes.

Change

Reuse one pointer monitor for each saturation box, hue strip, and opacity strip, and dispose it with the control.

Before

When running editor-color-picker-drag-color-area 37 times, GlobalPointerMoveMonitor grows by 111 instances:

before

After

No more leak detected.

Test Video

test-video.webm

AI disclosure: Model: GPT-6. Worktime: 8 min

Copilot AI balanced review requested due to automatic review settings November 1, 2026 23:07

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.

🟢 Approval recommended

No active review issues were identified in the change to reuse color-picker pointer monitors.

No open issues 🎉

What changed in this PR

Fixes a memory leak in the editor color picker by reusing pointer monitors instead of retaining a new monitor after every drag.

Changes:

  • Gives each saturation box, hue strip, and opacity strip one monitor, disposed with its control.
  • Adds regression tests checking that repeated drags do not increase tracked disposables and still flush color changes.
File Description
src/​vs/​editor/​contrib/​colorPicker/​test/​browser/​colorPickerPointerMonitor.test.ts Tests repeated-drag resource cleanup and color flushing for all three controls.
src/​vs/​editor/​contrib/​colorPicker/​browser/​colorPickerParts/​colorPickerStrip.ts Reuses one pointer monitor per hue or opacity strip.
src/​vs/​editor/​contrib/​colorPicker/​browser/​colorPickerParts/​colorPickerSaturationBox.ts Reuses one pointer monitor and simplifies monitoring-state checks.

Review effort: Balanced

@dmitrivMS Dmitriy Vasyura (dmitrivMS) added freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues editor-color-picker Editor color picker widget issues labels Nov 4, 2026

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.

🟢 Approval recommended

No active review issues remain for the pointer-monitor reuse change, though tests were not run during this review.

No open issues 🎉

Review effort: Max

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 7f89533 into microsoft:main Nov 4, 2026
59 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 4, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-colorPicker branch November 5, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

editor-color-picker Editor color picker widget issues freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants