Change:
have an eager comments controller extension (see below) open a notebook create a new cell leak warnings are printed
This seems to be rooted at  It looks like a new is created without always disposing the old one. The looks highly suspicious. <img width="1586" alt="Screenshot 2022-10-26 at 14 09 41" src="https://user-"
Suggesting to tackle this for October because after a short while VS Code was crawling due to excessive listening
thanks for good reproduce. The comment thread equality check is wrong, it's an oversight during refactoring iirc. I pushed a fix for this memory leak. Though with it fixed, I found there are issues with "Editing" state of comment thread for cells (focus issue), will look into this next week.
Thanks

Discussion:
} updateCommentThread(commentThread: languages.CommentThread<T>) { <del> if (this._commentThread !== commentThread) { dispose(this._commentThreadDisposables); } </del> this._commentThread = commentThread; <ins> dispose(this._commentThreadDisposables); </ins> this._commentThreadDisposables = []; this._bindCommentThreadListeners();

*  Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ <del> import * as dom from 'vs/base/browser/dom'; </del> import * as languages from 'vs/editor/common/languages'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';

this.commentTheadDisposables.add(this._commentThreadWidget.onDidResize(() => { if (this.currentElement?.cellKind === CellKind.Code && this._commentThreadWidget) { <del> this.currentElement.commentHeight = dom.getClientArea(this._commentThreadWidget.container).height; </del> <ins> this.currentElement.commentHeight = this._calculateCommentThreadHeight(this._commentThreadWidget.getDimensions().height); </ins> } })); }

this._createCommentTheadWidget(info.owner, info.thread); const layoutInfo = (this.currentElement as CodeCellViewModel).layoutInfo; this.container.style.top = `${layoutInfo.outputContainerOffset + layoutInfo.outputTotalHeight}px`; <del> this.currentElement.commentHeight = dom.getClientArea(this._commentThreadWidget!.container).height; </del> <ins> this.currentElement.commentHeight = this._calculateCommentThreadHeight(this._commentThreadWidget!.getDimensions().height); </ins> return; } if (this._commentThreadWidget) { <del> if (info) { this._commentThreadWidget.updateCommentThread(info.thread); this.currentElement.commentHeight = dom.getClientArea(this._commentThreadWidget.container).height; } else { </del> <ins> if (!info) { </ins> this._commentThreadWidget.dispose(); this.currentElement.commentHeight = 0; <ins> return; } if (this._commentThreadWidget.commentThread === info.thread) { this.currentElement.commentHeight = this._calculateCommentThreadHeight(this._commentThreadWidget.getDimensions().height); return; </ins> } <ins> this._commentThreadWidget.updateCommentThread(info.thread); this.currentElement.commentHeight = this._calculateCommentThreadHeight(this._commentThreadWidget.getDimensions().height); </ins> } } })); } <ins> private _calculateCommentThreadHeight(bodyHeight: number) { const layoutInfo = this.notebookEditor.getLayoutInfo(); const headHeight = Math.ceil(layoutInfo.fontInfo.lineHeight * 1.2); const lineHeight = layoutInfo.fontInfo.lineHeight; const arrowHeight = Math.round(lineHeight / 3); const frameThickness = Math.round(lineHeight / 9) * 2; const computedHeight = headHeight + bodyHeight + arrowHeight + frameThickness + 8 /** margin bottom to avoid margin collapse */; return computedHeight; } </ins> private async _getCommentThreadForCell(element: ICellViewModel): Promise<{ thread: languages.CommentThread<ICellRange>; owner: string } | null> { if (this.notebookEditor.hasModel()) { const commentInfos = coalesce(await this.commentService.getNotebookComments(element.uri));

override prepareLayout(): void { if (this.currentElement?.cellKind === CellKind.Code && this._commentThreadWidget) { <del> this.currentElement.commentHeight = dom.getClientArea(this._commentThreadWidget.container).height; </del> <ins> this.currentElement.commentHeight = this._calculateCommentThreadHeight(this._commentThreadWidget.getDimensions().height); </ins> } }