From e38c1f0657f3c4ea3500a31988591fafc823324a Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Tue, 10 Dec 2024 01:22:00 -0500 Subject: [PATCH] Fix leaking memory due to not improper cleanup of references to detached nodes (#1645) * Add missing event listeners removal in element-overflow-controller * Add missing clear dictionaries in element-overflow-controller * Add missing removeAllEventListeners to display-anki _onContentClear --- ext/js/display/display-anki.js | 1 + ext/js/display/element-overflow-controller.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js index 1ce12b09a..e33789c6a 100644 --- a/ext/js/display/display-anki.js +++ b/ext/js/display/display-anki.js @@ -249,6 +249,7 @@ export class DisplayAnki { this._updateDictionaryEntryDetailsToken = null; this._dictionaryEntryDetails = null; this._hideErrorNotification(false); + this._eventListeners.removeAllEventListeners(); } /** */ diff --git a/ext/js/display/element-overflow-controller.js b/ext/js/display/element-overflow-controller.js index 21a01d9e1..0321b441f 100644 --- a/ext/js/display/element-overflow-controller.js +++ b/ext/js/display/element-overflow-controller.js @@ -115,7 +115,9 @@ export class ElementOverflowController { /** */ clearElements() { this._elements.length = 0; + this._eventListeners.removeAllEventListeners(); this._windowEventListeners.removeAllEventListeners(); + this._dictionaries.clear(); } // Private