Skip to content

fix: memory leak in marker resource maps - #346501

Merged
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-marker-empty-maps
Nov 6, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 3 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-marker-empty-maps

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

Removing the final marker association leaves empty maps in both MarkerService indexes. Closed resources and disposed diagnostic collection names remain as keys after their markers have been cleared.

Change

Remove an outer resource or owner entry when its inner map becomes empty, preserving associations that still have markers.

Before

When creating, populating, and disposing diagnostic collections 17 times, the owner index keeps 17 additional empty maps and 612 bytes of collection-name strings. Total string growth is 920 bytes and 30 strings.

Before

After

The owner index stays empty. Total string growth is 360 bytes and 13 strings over the same 17 cycles; the remaining runtime and UI changes stay visible. The 612-byte owner-name saving is separate from 52 bytes of other variation.

After

Test Video

marker-empty-maps-native.webm

AI disclosure: Model: GPT 6.1 Sol. Worktime: 10 min

Copilot AI balanced review requested due to automatic review settings November 6, 2026 09:46

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.

🟡 Changes recommended

Missing regression tests for outer-index cleanup and retention of partially populated indexes through both changeOne and changeAll leave the leak undetectable by existing read() assertions.

1 open issue
What changed in this PR

Fixes retained empty maps in MarkerService by removing resource and owner keys after their final marker association is deleted.

Changes:

  • Prunes empty entries from both backing indexes.
  • Preserves entries that still contain associations.
File Description
src/​vs/​platform/​markers/​common/​markerService.ts Removes empty resource and owner entries during association deletion.

Review effort: Balanced

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Nov 6, 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 marker-index memory-leak fix, although tests were not run during this review.

No open issues 🎉

1 resolved since last review

Review effort: Max

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit be3dac0 into microsoft:main Nov 6, 2026
51 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 6, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-marker-empty-maps branch November 11, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

5 participants