Skip to content

Conversation

@SimonSiefke
Copy link
Contributor

Fixes a memory leak in local process extension host by setting the port message listener to null on dispose

portPromise.then((port) => {
	this._register(toDisposable(() => {
		port.close();
		port.onmessage = null; // here
	}));
	clearTimeout(handle);

});

Also changes this._toDispose.add to using this._register which overall seems a bit simpler.

Before & After Comparison

Barely noticable, but one can see at the bottom there is one less leak.

Untitled (5)

The chart shows restarting extensions 97 times, before and after.

Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@alexdima alexdima enabled auto-merge (squash) December 15, 2025 22:11
@alexdima alexdima disabled auto-merge December 15, 2025 22:11
@alexdima alexdima enabled auto-merge (squash) December 15, 2025 22:11
@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Dec 15, 2025
@alexdima alexdima merged commit 8f973b5 into microsoft:main Dec 15, 2025
17 checks passed
przpl pushed a commit to przpl/vscode that referenced this pull request Dec 16, 2025
* fix: memory leak in local process extension host

* clean

* clear promise
@SimonSiefke SimonSiefke deleted the fix/memory-leak-local-process-extension-host branch January 15, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants