Skip to content

[Bug] High renderer memory retention with wrappingStrategy: "advanced" on large text in Electron (memory does not drop after closing file) #5311

@ssnangua

Description

@ssnangua

Description

I'm using Monaco Editor in an Electron app as a read-only large text reader.
When wrappingStrategy is set to "advanced" and a large TXT file is loaded, renderer memory grows significantly and does not drop after closing the file (even after waiting and manual GC).
With "simple" wrapping, memory usually drops after a few seconds.

This looks like renderer-native memory retention (outside JS heap), potentially related to advanced wrapping/layout caches.

Environment

  • Monaco Editor: 0.55.1
  • Electron: 35.1.4
  • OS: Windows 10 (10.0.19045)
  • App mode: Renderer process in Electron, read-only editor
  • Typical test file: ~50MB TXT (very large line count, ~900k+ lines in one sample)

Monaco configuration (relevant)

monaco.editor.create(container, {
  readOnly: true,
  wordWrap: "on",
  wrappingStrategy: "advanced", // key trigger
  automaticLayout: true,
  minimap: { enabled: false },
  lineNumbers: "off",
});

Reproduction Steps

  1. Launch Electron app (initial renderer memory is low, e.g. ~250MB).
  2. Open a large TXT file (~50MB).
  3. Wait until loading/rendering completes.
  4. Enable wrappingStrategy: "advanced".
  5. Observe renderer process memory in Process Explorer / Task Manager.
  6. Close the file (editor model is cleared/replaced by empty content).
  7. Wait 30+ seconds and trigger manual GC in DevTools Memory panel.

This is my application, which can reproduce this issue: https://github.com/ssnangua/ColorTxt/releases/tag/v1.4.2
Sorry, because it is aimed at Chinese users, so there is no English version yet, but you can refer to the example image below for instructions.
Image

Actual (Problematic) Behavior

  • With "advanced", renderer memory rises sharply (often several GB in our tests) and does not noticeably drop after closing file, waiting, and manual GC.
  • DevTools JS heap remains relatively small (example: ~385MB), while renderer private bytes/working set remains very high (example: 4–6GB).
  • Closing the renderer process/window releases memory immediately.

Expected Behavior

  • Renderer memory should drop significantly after file close and GC (or within a reasonable delay), similar to "simple" wrapping behavior.

Additional Context

  • Same file with wrappingStrategy: "simple":
    • memory increases during load/render,
    • then usually drops after closing file (with some delay).
  • Problem is strongly correlated with "advanced" mode.
  • This does not look like a pure JS heap leak; it appears to be renderer-native/external memory retention.

Process-level evidence

In Electron process tree, the high memory is in the renderer process (not main process).
GPU process is not the main contributor in our case.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions