fix: add new emitter API to prevent memory leak #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is a better fix for vaadin/web-components#6480. See the discussion in vaadin/web-components#7547 (comment)
Once this is merged, the
vaadin-rich-text-editor
should be updated to revert vaadin/web-components#6506 so that we only initialize Quill inready()
and then just callemitter.connect()
andemitter.disconnect()
in corresponding lifecycle callbacks of the web component:connectedCallback()
/disconnectedCallback()
Here's a comparison of the JS memory heap snapshots after calling
detach
/reattach
for theRichTextEditor
20 times:Without a fix
Tested after just reverting thtps://github.com/vaadin/web-components/pull/6506 - note the emitters aren't GCed:
With a fix
While new web component is created on re-attach, calling
emitter.disconnect()
allows it to be GCed so there's only one:Type of change