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 settings editor memory leak #216763

Merged
merged 3 commits into from
Jun 21, 2024

Conversation

SimonSiefke
Copy link
Contributor

Helps with #216649

Stack Trace

By measuring growing disposable stores, it showed this stack trace very often:

SettingsEditor2._register (vscode/out/vs/base/common/lifecycle.js:393:32)\nvscode/out/vs/workbench/contrib/preferences/browser/settingsEditor2.js:264:22
// settingsEditor2.js
this._register(input.onWillDispose(() => {
	this.searchWidget.setValue('');
}));

Possible memory leak cause

It seems when all editors are closed, the last opened editor always remains. But when setting a new editor input, a input.onWillDispose listener is added to the SettingsEditor2. When opening the SettingsEditor2 again, a new input.onWillDispose listener is added to the initial SettingsEditor2.

Testing

For testing, I ran the same test script opening and closing the settings editor 197 times which showed that the number of SettingsEditor2Input instances was reduced from 197 to 2.

@rzhao271 rzhao271 added this to the June 2024 milestone Jun 21, 2024
@rzhao271 rzhao271 enabled auto-merge (squash) June 21, 2024 23:49
@rzhao271 rzhao271 merged commit e47ec0a into microsoft:main Jun 21, 2024
6 checks passed
bricefriha pushed a commit to bricefriha/vscode that referenced this pull request Jun 26, 2024
* try to fix settings editor memory leak

* clean up code

* remove unused clear
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Aug 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants