-
Notifications
You must be signed in to change notification settings - Fork 33.4k
fix: memory leak in codeCell #205616
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
base: main
Are you sure you want to change the base?
fix: memory leak in codeCell #205616
Conversation
src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.ts
Outdated
Show resolved
Hide resolved
return; | ||
} | ||
|
||
if (model) { | ||
this._register(model); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems legit, but I'll leave it to someone else to make the call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roblourens I'm not sure if it's a good idea to dispose the model since BaseCellViewModel
has a model ref _textModelRef
. Disposing the model here would leave us an obsolete _textModelRef
and textModel
.
fixes #186361
When scrolling a notebook up and down, I found the largest amount of detached dom nodes was this:
More details
In the
initializeEditor
afterresolveTextModel.then
themodel
disposable is not registered, which seemingly causes a memory leak when scrolling in the notebook.Fix
Now the model is registered, similar to other disposables:
For some reason, registering the model didn't fix the issue entirely, which is why there is also (copied from
commentsController
) this code:With both changes in place, the number of detached
div.monaco-editor
dom nodes when scrolling a notebook up and down 1997 times was reduced from 3997 to 0.