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

Memory leak in settings editor #216649

Closed
SimonSiefke opened this issue Jun 19, 2024 · 1 comment
Closed

Memory leak in settings editor #216649

SimonSiefke opened this issue Jun 19, 2024 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug settings-editor VS Code settings editor issues
Milestone

Comments

@SimonSiefke
Copy link
Contributor

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.90.2
  • OS Version: Ubuntu 24.04

Steps to Reproduce:

  1. Open the settings ui editor
  2. Close the settings ui editor
  3. Repeat a few times
  4. Notice that the number the number of SettingsEditor2Input and Settings2EditorModel grows by 1 each time, for example, opening and closing the settings editor 197 times, increases the number of SettingsEditor2Input and Settings2EditorModel by 197:
{
  "instanceCountsDifferenceWithSourceMap": [
    {
      "name": "DisposableStore",
      "count": 15109,
      "beforeCount": 4773,
      "url": "/src/vs/base/common/lifecycle.ts:370:1"
    },
    {
      "name": "Emitter",
      "count": 14937,
      "beforeCount": 4793,
      "url": "/src/vs/base/common/event.ts:1020:13"
    },
    {
      "name": "LeakageMonitor",
      "count": 14891,
      "beforeCount": 4747,
      "url": "/src/vs/base/common/event.ts:838:19"
    },
    {
      "name": "SettingsTreeSettingElement",
      "count": 9802,
      "beforeCount": 1430,
      "url": "/src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts:168:2"
    },
    {
      "name": "Node",
      "count": 6289,
      "beforeCount": 6285,
      "url": "/src/vs/base/common/linkedList.ts:14:13"
    },
    {
      "name": "UniqueContainer",
      "count": 3986,
      "beforeCount": 3715,
      "url": "/src/vs/base/common/event.ts:934:29"
    },
    {
      "name": "DomListener",
      "count": 2680,
      "beforeCount": 2187,
      "url": "/src/vs/base/browser/dom.ts:138:13"
    },
    {
      "name": "KeyCodeChord",
      "count": 1070,
      "beforeCount": 1069,
      "url": "/src/vs/base/common/keybindings.ts:82:18"
    },
    {
      "name": "EventDeliveryQueuePrivate",
      "count": 1030,
      "beforeCount": 445,
      "url": "/src/vs/base/common/event.ts:1248:0"
    },
    {
      "name": "Uri",
      "count": 816,
      "beforeCount": 619,
      "url": "/src/vs/base/common/uri.ts:447:0"
    },
    {
      "name": "ContextKey",
      "count": 561,
      "beforeCount": 560,
      "url": "/src/vs/platform/contextkey/browser/contextKeyService.ts:199:13"
    },
    {
      "name": "SettingsTreeGroupElement",
      "count": 535,
      "beforeCount": 79,
      "url": "/src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts:88:13"
    },
    {
      "name": "MenuItemAction",
      "count": 332,
      "beforeCount": 258,
      "url": "/src/vs/platform/actions/common/actions.ts:482:2"
    },
    {
      "name": "Action",
      "count": 292,
      "beforeCount": 241,
      "url": "/src/vs/base/common/actions.ts:68:13"
    },
    {
      "name": "DomEmitter",
      "count": 241,
      "beforeCount": 233,
      "url": "/src/vs/base/browser/event.ts:39:13"
    },
    {
      "name": "SettingsEditor2Input",
      "count": 200,
      "beforeCount": 3,
      "url": "/src/vs/workbench/services/preferences/common/preferencesEditorInput.ts:30:23"
    },
    {
      "name": "Settings2EditorModel",
      "count": 200,
      "beforeCount": 3,
      "url": "/src/vs/workbench/services/preferences/common/preferencesModels.ts:224:10"
    },
    {
      "name": "MutableDisposable",
      "count": 171,
      "beforeCount": 163,
      "url": "/src/vs/base/common/lifecycle.ts:511:1"
    },
    {
      "name": "DisposableMap",
      "count": 116,
      "beforeCount": 115,
      "url": "/src/vs/base/common/lifecycle.ts:718:1"
    },
    {
      "name": "Separator",
      "count": 113,
      "beforeCount": 78,
      "url": "/src/vs/base/common/actions.ts:198:0"
    },
    {
      "name": "Lazy",
      "count": 111,
      "beforeCount": 78,
      "url": "/src/vs/base/common/lazy.ts:13:19"
    },
    {
      "name": "RunOnceScheduler",
      "count": 105,
      "beforeCount": 98,
      "url": "/src/vs/base/common/async.ts:975:13"
    },
    {
      "name": "FocusTracker",
      "count": 82,
      "beforeCount": 81,
      "url": "/src/vs/base/browser/dom.ts:1334:13"
    },
    {
      "name": "DebugNameData",
      "count": 74,
      "beforeCount": 52,
      "url": "/src/vs/base/common/observableInternal/debugName.ts:28:18"
    },
    {
      "name": "ConfigurationInspectValue",
      "count": 65,
      "beforeCount": 17,
      "url": "/src/vs/platform/configuration/common/configurationModels.ts:511:19"
    }
  ]
}

Test script

git clone git@github.com:SimonSiefke/vscode-memory-leak-finder.git &&
cd vscode-memory-leak-finder &&
git checkout v5.46.0 &&
npm ci &&
node packages/cli/bin/test.js --cwd packages/e2e --only  settings.open --watch --check-leaks --measure-after --measure instance-counts-difference-with-source-map --runs 197 &&
cat .vscode-memory-leak-finder-results/instance-counts-difference-with-source-map/settings.open.json

Additional Information

In addition to SettingsEditor2Input and Settings2EditorModel, the number of URI instances increases also by 197 which seems to be the URI from https://github.com/microsoft/vscode/blob/main/src/vs/workbench/services/preferences/common/preferencesEditorInput.ts#L24-L27:

export class SettingsEditor2Input extends EditorInput {
	readonly resource: URI = URI.from({
		scheme: Schemas.vscodeSettings,
		path: `settingseditor`
	});

The SettingsEditor2Input is created in https://github.com/microsoft/vscode/blob/main/src/vs/workbench/services/preferences/browser/preferencesService.ts#L108:

createSettingsEditor2Input(): SettingsEditor2Input {
	return new SettingsEditor2Input(this);
}

which then passed to the openEditor function:

	private async openSettings2(options: IOpenSettingsOptions): Promise<IEditorPane> {
		const input = this.createSettingsEditor2Input();
		options = {
			...options,
			focusSearch: true
		};
		await this.editorService.openEditor(input, validateSettingsEditorOptions(options), options.openToSide ? SIDE_GROUP : undefined);
		return this.editorGroupService.activeGroup.activeEditorPane!;
	}
@SimonSiefke
Copy link
Contributor Author

Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug settings-editor VS Code settings editor issues
Projects
None yet
Development

No branches or pull requests

3 participants