Skip to content

fix: memory leak in mainThreadLanguages#283498

Merged
connor4312 merged 1 commit intomicrosoft:mainfrom
SimonSiefke:fix/memory-leak-main-thread-languages
Dec 15, 2025
Merged

fix: memory leak in mainThreadLanguages#283498
connor4312 merged 1 commit intomicrosoft:mainfrom
SimonSiefke:fix/memory-leak-main-thread-languages

Conversation

@SimonSiefke
Copy link
Copy Markdown
Contributor

Fixes a memory leak in mainThreadLanguages.

Details

The code currently uses

this._status.get(handle)?.dispose();

However that code only disposes the entry, but doesn't remove it from this._status.

Change

Thankfully, DisposableMap provides deleteAndDispose which both disposes the entry and removes it from the map:

this._status.deleteAndDispose(handle);

Also there are some minor code changes trying to simplify the code a bit.

Before

When toggling semantic tokens 37 times, the number of LanguageFeatureRegistry.register functions seems to grow by 1 each time:

editor toggle-semantic-tokens

After

No more leak detected

@connor4312 connor4312 enabled auto-merge (squash) December 15, 2025 03:51
@connor4312
Copy link
Copy Markdown
Member

thanks!

@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Dec 15, 2025
@connor4312 connor4312 merged commit 0d1ac13 into microsoft:main Dec 15, 2025
17 checks passed
@SimonSiefke SimonSiefke deleted the fix/memory-leak-main-thread-languages branch January 15, 2026 15:08
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

3 participants