Skip to content

Commit c4141cf

Browse files
authored
Add missing disposals (microsoft#155976)
* Add missing disposals I did some V8 heap profiling and found a few more places where references to closed terminals prevents them from being garbage collected. * Let closed terminals be garbage collected Action bars are not disposed when a terminal is closed, they are cached in the list until you open a new terminal, so manually clear it to make it possible to garbage collect the closed terminal directly.
1 parent ac4d678 commit c4141cf

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
537537
this._labelComputer?.refreshLabel();
538538
}
539539
}));
540-
this._workspaceContextService.onDidChangeWorkspaceFolders(() => this._labelComputer?.refreshLabel());
540+
this.addDisposable(this._workspaceContextService.onDidChangeWorkspaceFolders(() => this._labelComputer?.refreshLabel()));
541541

542542
// Clear out initial data events after 10 seconds, hopefully extension hosts are up and
543543
// running at that point.
@@ -760,11 +760,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
760760

761761
this._loadTypeAheadAddon(xterm);
762762

763-
this._configurationService.onDidChangeConfiguration(e => {
763+
this.addDisposable(this._configurationService.onDidChangeConfiguration(e => {
764764
if (e.affectsConfiguration(TerminalSettingId.LocalEchoEnabled)) {
765765
this._loadTypeAheadAddon(xterm);
766766
}
767-
});
767+
}));
768768

769769
this._pathService.userHome().then(userHome => {
770770
this._userHome = userHome.fsPath;

src/vs/workbench/contrib/terminal/browser/terminalTabsList.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,14 @@ class TerminalTabsRenderer implements IListRenderer<ITerminalInstance, ITerminal
458458
disposeElement(instance: ITerminalInstance, index: number, templateData: ITerminalTabEntryTemplate): void {
459459
templateData.elementDisposables?.dispose();
460460
templateData.elementDisposables = undefined;
461+
templateData.actionBar.clear();
461462
}
462463

463464
disposeTemplate(templateData: ITerminalTabEntryTemplate): void {
464465
templateData.elementDisposables?.dispose();
465466
templateData.elementDisposables = undefined;
466467
templateData.label.dispose();
468+
templateData.actionBar.clear();
467469
}
468470

469471
fillActionBar(instance: ITerminalInstance, template: ITerminalTabEntryTemplate): void {

src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
7676
this._register(this._contextMenuService.onDidHideContextMenu(() => this._contextMenuVisible = false));
7777
this._hoverDelayer = this._register(new Delayer(this._configurationService.getValue('workbench.hover.delay')));
7878

79-
this._configurationService.onDidChangeConfiguration(e => {
79+
this._register(this._configurationService.onDidChangeConfiguration(e => {
8080
if (e.affectsConfiguration(TerminalSettingId.ShellIntegrationDecorationIcon) ||
8181
e.affectsConfiguration(TerminalSettingId.ShellIntegrationDecorationIconSuccess) ||
8282
e.affectsConfiguration(TerminalSettingId.ShellIntegrationDecorationIconError)) {
@@ -92,8 +92,8 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
9292
}
9393
this._updateDecorationVisibility();
9494
}
95-
});
96-
this._themeService.onDidColorThemeChange(() => this._refreshStyles(true));
95+
}));
96+
this._register(this._themeService.onDidColorThemeChange(() => this._refreshStyles(true)));
9797
this._updateDecorationVisibility();
9898
this._register(this._capabilities.onDidAddCapability(c => {
9999
if (c === TerminalCapability.CommandDetection) {

0 commit comments

Comments
 (0)