aux window - fix setTimeout leak#311824
Merged
bpasero merged 1 commit intomicrosoft:mainfrom Apr 23, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a memory leak in the workbench’s multi-window setTimeout monkey-patching so timer disposables don’t accumulate in the main window’s per-window DisposableStore when auxiliary windows are open.
Changes:
- When a timeout disposable runs, it now removes itself from the owning window’s
DisposableStoreusingdeleteAndLeak, preventing retained references after disposal.
pwang347
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #311823
Normally when the window is defocused, the browser will throttle any timeouts set on it. In VSCode there is a concept of aux windows, and timeouts set on the main window must not be throttled when the user is working in the aux window. There is some special code to do this in enableMultiWindowAwareTimeout by monkey-patching setTimeout in the main window + aux windows.
This code contained a memory leak where any call to setTimeout with >0 auxwindows would insert a dispose function into the main window's disposables table and never clean it up, even after calling it. I work on Cursor which is built on VSCode, and our app calls setTimeout something like 400 times per second and this was causing my app to have 230MB+ retained just by the main window disposables table.