Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes/No <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: V1.81.1 OS Version: Linux kkuser-virtual-machine 5.15.0-83-generic ~20.04.1-Ubuntu SMP Mon Aug 21 14:00:49 UTC 2023 x8664 x8664 x8664 GNU/Linux Steps to Reproduce: are constant changes in attribute states in the treeview calls to () functions result in memory leakage
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.82.2. Please try upgrading to the latest version and checking whether this issue remains. Happy Coding!
<!-- AUTHORVERIFICATIONREQUEST --This bug has been fixed in the latest release of ! you can help us out by commenting if things are now working as expected. If things still don't seem right, please ensure you're on version of Insiders (today's or later - you can use in the command palette to check), and leave a comment letting us know what isn't working as expected. Happy Coding!

Discussion:
templateData.actionBar.context = <TreeViewItemHandleArg>{ $treeViewId: this.treeViewId, $treeItemHandle: node.handle }; <del> const menuActions = this.menus.getResourceActions(node); if (menuActions.menu) { templateData.elementDisposable.add(menuActions.menu); } </del> <ins> const menuActions = this.menus.getResourceActions(node, templateData.elementDisposable); </ins> templateData.actionBar.push(menuActions.actions, { icon: true, label: false }); if (this._actionRunner) {

} } <del> class TreeMenus extends Disposable implements IDisposable { </del> <ins> class TreeMenus implements IDisposable { </ins> private contextKeyService: IContextKeyService | undefined; private _onDidChange = new Emitter<ITreeItem>(); public readonly onDidChange = this._onDidChange.event;

constructor( private id: string, @IMenuService private readonly menuService: IMenuService <del> ) { super(); } </del> <ins> ) { } </ins> <del> /** * Caller is now responsible for disposing of the menu! */ getResourceActions(element: ITreeItem): { menu?: IMenu; actions: IAction[] } { const actions = this.getActions(MenuId.ViewItemContext, element, true); </del> <ins> getResourceActions(element: ITreeItem, disposableStore: DisposableStore): { menu?: IMenu; actions: IAction[] } { const actions = this.getActions(MenuId.ViewItemContext, element, disposableStore); </ins> return { menu: actions.menu, actions: actions.primary }; }

this.contextKeyService = service; } <del> private getActions(menuId: MenuId, element: ITreeItem, listen: boolean = false): { menu?: IMenu; primary: IAction[]; secondary: IAction[] } { </del> <ins> private getActions(menuId: MenuId, element: ITreeItem, listen?: DisposableStore): { menu?: IMenu; primary: IAction[]; secondary: IAction[] } { </ins> if (!this.contextKeyService) { return { primary: [], secondary: [] }; }

const result = { primary, secondary, menu }; createAndFillInContextMenuActions(menu, { shouldForwardArgs: true }, result, 'inline'); if (listen) { <del> this._register(menu.onDidChange(() => this._onDidChange.fire(element))); </del> <ins> listen.add(menu.onDidChange(() => this._onDidChange.fire(element))); listen.add(menu); </ins> } else { menu.dispose(); } return result; } <del> override dispose() { </del> <ins> dispose() { </ins> this.contextKeyService = undefined; <del> super.dispose(); </del> } }