Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in comments browser #205162

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/vs/workbench/contrib/comments/browser/commentNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as dom from 'vs/base/browser/dom';
import * as languages from 'vs/editor/common/languages';
import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { Action, IActionRunner, IAction, Separator, ActionRunner } from 'vs/base/common/actions';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { ITextModel } from 'vs/editor/common/model';
import { IModelService } from 'vs/editor/common/services/model';
Expand Down Expand Up @@ -576,12 +576,10 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable {

this._commentEditorModel?.dispose();

this._commentEditorDisposables.forEach(dispose => dispose.dispose());
dispose(this._commentEditorDisposables);
this._commentEditorDisposables = [];
if (this._commentEditor) {
this._commentEditor.dispose();
this._commentEditor = null;
}
this._commentEditor?.dispose();
this._commentEditor = null;

this._commentEditContainer!.remove();
}
Expand Down Expand Up @@ -766,6 +764,11 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable {
}, 3000);
}
}

override dispose(): void {
super.dispose();
dispose(this._commentEditorDisposables);
}
}

function fillInActions(groups: [string, Array<MenuItemAction | SubmenuItemAction>][], target: IAction[] | { primary: IAction[]; secondary: IAction[] }, useAlternativeActions: boolean, isPrimaryGroup: (group: string) => boolean = group => group === 'navigation'): void {
Expand Down
6 changes: 5 additions & 1 deletion src/vs/workbench/contrib/comments/browser/commentReply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as dom from 'vs/base/browser/dom';
import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor/mouseCursor';
import { IAction } from 'vs/base/common/actions';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
import { MarshalledId } from 'vs/base/common/marshallingIds';
import { URI } from 'vs/base/common/uri';
import { generateUuid } from 'vs/base/common/uuid';
Expand Down Expand Up @@ -369,4 +369,8 @@ export class CommentReply<T extends IRange | ICellRange> extends Disposable {
});
}

override dispose(): void {
super.dispose();
dispose(this._commentThreadDisposables);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export class CommentThreadWidget<T extends IRange | ICellRange = IRange> extends

override dispose() {
super.dispose();
dispose(this._commentThreadDisposables);
this.updateCurrentThread(false, false);
}

Expand Down