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

General Memory leaks when using the quill editor #3749

Closed
JeffMosaic opened this issue Feb 20, 2023 · 2 comments
Closed

General Memory leaks when using the quill editor #3749

JeffMosaic opened this issue Feb 20, 2023 · 2 comments

Comments

@JeffMosaic
Copy link

Quill appears to be leaking memory in general. In my current use case I have an application that creates and removes many instances of Quill on a single page. Doing some memory leak analysis it appears that many of the event emitters used between the quill editor and the keyboard/scroll/modules systems result in memory leaks.

Steps for Reproduction

While a bit of a crude reproduction I was able to use the playground to reproduce a form of this memory leak.

  1. Visit https://quilljs.com/playground/
  2. Enter the following into JS section of the playground
var lastId = 0;

setInterval(() => {
  // Proxy metric to show growth only works in chrome
  console.log(performance.memory)
}, 5000)

document.getElementById('add-editor').onclick = () => {
  var el = document.createElement('div');
  var id = `editor-container-${lastId++}`;
  el.id = id;
  var existingArea = document.getElementById('editor-area');
  existingArea.append(el);
  var largeValue = new Array(999999);
  largeValue.fill(9);
  new Quill('#' + id, {
    modules: {
      toolbar: null
    },
    placeholder: 'Compose an epic...',
    theme: 'snow',  // or 'bubble',
    foo: largeValue
  });
}

document.getElementById('remove-editor').onclick = () => {
  var targetEditor = `editor-container-${--lastId}`;
  document.getElementById(targetEditor).remove();
}
  1. Enter the following into the html section of the playground
<div>
  <button id="add-editor">Add Editor</button>
  <button id="remove-editor">Remove Editor</button>
  <div id="editor-area"></div>
</div>
  1. Create multiple editors
  2. Remove those editors

Expected behavior:
Memory should eventually go down and stay down

Actual behavior:
Memory keeps climbing higher and higher with each new set of added/removed editors

Platforms:
MacOS Monterey 12.5.1 Chrome 109.0.5414.87 (but I suspect this applies to many other versions)

Version:
1.3.7

@JeffMosaic
Copy link
Author

This might be related to #3644 but given #3359 I am unsure of the state of this project

@quill-bot
Copy link

Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide 🙏

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

No branches or pull requests

2 participants