microsoft / microsoft/monaco-editor
[Bug] Memory usage increases linearly when adding/removing monaco embedded in same-origin iframes in Chrome
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
No response
Monaco Editor Playground Code
External repro here: https://github.com/awphi/monaco-chrome-iframe-issue/
Reproduction Steps
- Clone this repo
pnpm install && pnpm dev(or whatever package manager)- Open the app in Chrome
- Open the Performance Monitor in DevTools
- Repeatedly press the add/remove iframe button
- Observe memory usage and retained document/document frame count increase
https://github.com/user-attachments/assets/befeae8d-a62f-4e99-8627-c7f184ae8c23
Actual (Problematic) Behavior
Memory usage increases linearly with number of total iframes created in the page's lifespan.
Expected Behavior
Documents using monaco are not retained after its containing iframe is removed, preventing significant memory retention.
Additional Context
Browser Versions: Version 133.0.6943.142 (Official Build) (arm64), Version 135.0.7039.1 (Official Build) canary-dcheck (arm64)
OS: MacOS 15.3.1 (24D70)
Interestingly, reducing the text length in the model (e.g. change the dummy HTML in the above repro to abc) seems to circumvent this issue.
Also doesn't seem to affect FF 135.0.1 afaict
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Clone the linked external reproduction, run pnpm install && pnpm dev, and reproduce the issue in Chrome with Performance Monitor open while repeatedly adding and removing iframes. Trace the retained documents and document frames; done means Monaco documents are no longer retained after their containing iframe is removed, without reproducing the reported memory increase.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100