codex-team / editor.js

A block-style editor with clean JSON output
https://editorjs.io
Apache License 2.0
28.88k stars 2.09k forks source link

Massive memory leak: all DOM nodes will be retained forever #2866

Open WolfBearGames opened 2 weeks ago

WolfBearGames commented 2 weeks ago

When using the Editor and loading longer and multiple document the number of DOM nodes in the document keeps growing and never goes down again. Using Chrome Developer tools memory analyzer and looking for "detached DOM nodes" shows all the "ce-block" divs that were ever loaded in the editor.

Steps to reproduce:

  1. Load some content into the editor (the demo website will do)
  2. delete the content or load new content
  3. look at the Chrome Developer Tools memory Analyzer

Expected behavior: the DOM nodes are not retained forever, but get garbage collected after they have been deleted or a new document has been loaded (using render())

Editor.js version: 2.30.6 (but i think all version will be affected)

Plugins you use with their versions: multiple, but the problem also occurs with the demo website and the default plugins. The problem is in the core of the editor.

I consider this a major bug, because it means every longer running application using the Editor will leak memory until it gets unusable.

WolfBearGames commented 2 weeks ago

Even calling destroy() on the Editor instance and setting the Editor reference to null does not release the DOM nodes.