-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 plugin tree views #10404
Comments
@xcariba What makes you say that old nodes are not properly disposed? How would nodes escape being disposed when refreshing the root with id |
@tsmaeder I have a custom (proprietary) extension that uses tree view and first implementation was constantly updating. In chrome developer tools I found out that when frequent updates occur memory consumption can go (from ~35mb up to ~1Gb). So I optimized my code so that it sends updates a lot less frequent. It still consumes a lot of memory after some time, but now it can work for a ~day before it reaches high numbers. |
@xcariba do the "new" elements have the same id's as the "old" elements or do they always change? |
@tsmaeder they have same ids |
Looking at the current implementation of the theia/packages/plugin-ext/src/plugin/tree/tree-views.ts Lines 373 to 376 in dacd392
The newly created top-level children are pushed to theia/packages/plugin-ext/src/plugin/tree/tree-views.ts Lines 402 to 406 in dacd392
However, theia/packages/plugin-ext/src/plugin/tree/tree-views.ts Lines 363 to 364 in dacd392
This causes two issues with regard to memory leaks:
As a result of the child nodes not being disposed, the associated commands placed into the theia/packages/plugin-ext/src/plugin/command-registry.ts Lines 187 to 188 in dacd392
As a result of this 'chaining' of the trees, the nodes accumulate on each refresh. This can cause a massive memory leak. The following screenshots illustrate the issue when opening Theia on the vscode-extension-samples/helloworld-sample workspace and using the As can be seen, the nodes accumulate each time the view is refreshed. It looks like it can be fixed by reusing the single root node instead of creating a new one each time the I can try to provide the patch, if needed. |
Fixes a bug in `TreeViewExtImpl<T>.getChildren(parentId: string)`, where newly created top-level children were added to the old root node instead of the new one. This caused a memory leak by retaining an implicit reference to the old root node from the new one and failing to properly track and, hence, dispose the top-level children. The fix ensures that old nodes get disposed and become subject to garbage collection by reusing the single root node instead of creating a new one on full refresh. See eclipse-theia#10404 (comment) for more information. Fixes eclipse-theia#10404.
Since this is a |
Fixes a bug in `TreeViewExtImpl<T>.getChildren(parentId: string)`, where newly created top-level children were added to the old root node instead of the new one. This caused a memory leak by retaining an implicit reference to the old root node from the new one and failing to properly track and, hence, dispose the top-level children. The fix ensures that old nodes get disposed and become subject to garbage collection by reusing the single root node instead of creating a new one on full refresh. See #10404 (comment) for more information. Fixes #10404.
Bug Description:
Theia always fetches whole tree in plugin tree views when change event is fired. (It calls tree refresh without argument and it causes complete refresh).
In tree-views.ts Theia calls clearChildren to dispose previous commands and remove children before new child elements are fetched.
When full refresh is called it begins with root node (with empty id) and old nodes are not properly disposed/removed. If tree is huge and is constantly updating it consumes several gb of memory and sometimes even crashes. I found out that old commands are not disposed and still kept in command registry (and maybe somewhere else). Same tree works fine in VSCode.
Steps to Reproduce:
Additional Information
The text was updated successfully, but these errors were encountered: