Skip to content

Conversation

@SimonSiefke
Copy link
Contributor

Fixes a memory leak in terminal chat widget.

Details

When toggling terminal inline chat, this disposable seems to be registered each time, making the number of registered disposables grow by 1 each time when opening the terminal inline chat

private async _createSession(): Promise<void> {
	this._register(toDisposable(() => this._sessionCtor?.cancel()));
}

Fix

Changing the code to use a MutableDisposable ensures that at most one session disposable registered.

private async _createSession(): Promise<void> {
	this._sessionDisposables.value = toDisposable(() => this._sessionCtor?.cancel());
}

Before

When opening and closing terminal inline 97 times, the number of functions in TerminalChatWidget seems to grow by 1 each time

terminal inline-chat-toggle-original

After

No more leak is detected.

@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Dec 18, 2025
@meganrogge
Copy link
Contributor

Thanks @SimonSiefke!

@meganrogge meganrogge merged commit beecac5 into microsoft:main Dec 18, 2025
17 checks passed
@SimonSiefke SimonSiefke deleted the fix/memory-leak-terminal-chat-widget branch January 15, 2026 15:06
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.

3 participants