Skip to content

fix: memory leak in tunnel view#287142

Merged
alexr00 merged 9 commits intomicrosoft:mainfrom
SimonSiefke:fix/memory-leak-tunnel-view
Feb 13, 2026
Merged

fix: memory leak in tunnel view#287142
alexr00 merged 9 commits intomicrosoft:mainfrom
SimonSiefke:fix/memory-leak-tunnel-view

Conversation

@SimonSiefke
Copy link
Contributor

Fixes some memory leaks in tunnel view.

Details

Table renderers and list renderers are special since they don't use this._register for registering disposables but instead templateDisposables and elementDisposables.

Change

Changes ActionBarRenderer to not be a disposable anymore since TableRenderers and ListRenderers are (almost?) always not Disposables.

Instead, the code now uses elementDisposables and templateDisposables to register the items.

Before

When opening the ports tunnel view and toggling the input 37 times, the number of functions seems to grow each time in ActionBarRenderer.renderButton and some other places:

ports-view-open-port

After

No more leak is detected.

Copilot AI review requested due to automatic review settings February 13, 2026 11:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses memory leaks in the Ports (tunnel) view table by aligning the ActionBarRenderer lifecycle with the table renderer model (template/element disposables), rather than relying on this._register() from a long-lived Disposable base class.

Changes:

  • Refactors ActionBarRenderer to no longer extend Disposable, and instead manage disposables via templateDisposables and elementDisposables.
  • Ensures per-element resources (e.g., menus, buttons, input handlers) are disposed by clearing elementDisposables on each render and in disposeElement.
  • Simplifies template disposal by disposing a single templateDisposables store in disposeTemplate.
Comments suppressed due to low confidence (2)

src/vs/workbench/contrib/remote/browser/tunnelView.ts:370

  • New statements in renderTemplate are missing semicolons (and the surrounding file consistently uses them). Please add semicolons here (and in the other newly added lines) to match the repo style and avoid ASI-related lint/format issues.
		const templateDisposables = new DisposableStore()
		const elementDisposables = new DisposableStore();
		templateDisposables.add(elementDisposables)
		const label = templateDisposables.add(new IconLabel(cell,

src/vs/workbench/contrib/remote/browser/tunnelView.ts:518

  • renderInputBox creates a new InputBox and appends it to the cell container each time edit mode is entered. Disposing InputBox does not remove its .element from the DOM (it only disposes listeners), so repeated toggling can accumulate hidden input DOM nodes in the row template. Consider either reusing a single InputBox stored on templateData or explicitly removing/clearing the created inputBox.element when finishing/disposing.
		const { container } = templateData
		container.style.paddingLeft = '5px';
		const value = editableData.startingValue || '';
		const inputBox = new InputBox(container, this.contextViewService, {
			ariaLabel: nls.localize('remote.tunnelsView.input', "Press Enter to confirm or Escape to cancel."),
			validationOptions: {
				validation: (value) => {
					const message = editableData.validationMessage(value);
					if (!message) {
						return null;
					}

					return {
						content: message.content,
						formatContent: true,
						type: message.severity === Severity.Error ? MessageType.ERROR : MessageType.INFO
					};
				}
			},
			placeholder: editableData.placeholder || '',
			inputBoxStyles: defaultInputBoxStyles
		});

@alexr00 alexr00 enabled auto-merge (squash) February 13, 2026 13:58
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@alexr00 alexr00 added this to the February 2026 milestone Feb 13, 2026
@alexr00 alexr00 merged commit e1f64b1 into microsoft:main Feb 13, 2026
17 checks passed
@SimonSiefke SimonSiefke deleted the fix/memory-leak-tunnel-view branch February 13, 2026 17:53
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