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

[Bug] Memory leaking when disposing Diff editor #4659

Open
2 tasks done
samirzubi-db opened this issue Aug 27, 2024 · 2 comments · May be fixed by microsoft/vscode#230713
Open
2 tasks done

[Bug] Memory leaking when disposing Diff editor #4659

samirzubi-db opened this issue Aug 27, 2024 · 2 comments · May be fixed by microsoft/vscode#230713

Comments

@samirzubi-db
Copy link

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

No response

Monaco Editor Playground Code

No response

Reproduction Steps

I wrote a small application demonstrating the issue:
You can find it on the following link: https://zd9n67.csb.app/
Code: https://codesandbox.io/p/sandbox/react-typescript-forked-zd9n67

Actual (Problematic) Behavior

Diff editor does not dispose correctly after being removed from the dom.
The regular editor component does not have this issue.

Initial load
initial_render

Second memory snapshot
second_take

Third memory snapshot
third_take

Fourth memory snapshot
fourth_take

The memory constantly grows as the diff editor is not properly disposed of. Form my investigation I could see that the Emitter and InteractionEmitter are constantly growing without being disposed in the monaco-editor/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget.js file.
Also a lot of detached canvas dom elements like:
<canvas class="original diffOverviewRuler" ...

Expected Behavior

Diff editor gets removed properly and does not cause a memory leak.

Additional Context

We started observing the issue in the 0.44.0 version of monaco-editor as the earlier versions don't seem to have this problem. The example is for the latest version 0.51.0

@alexanderwu-db
Copy link

Probably would be a good idea to write a unit test in the monaco editor library to test against memory leaks in the future?

@samirzubi-db
Copy link
Author

I've submitted a fix in the vscode repo in case anyone needs to fix this in their codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants