tinymce / tinymce-angular

Official TinyMCE Angular Component
MIT License
330 stars 92 forks source link

Memory Leak #90

Closed kherP closed 5 years ago

kherP commented 5 years ago

What is the current behavior? Editor object is retained in browser memory even after destroyed. image

Please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox.io or similar. Reproduction

What is the expected behavior? Memory should be cleared after editor is destroyed.

Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or tinymce-angular? 3.0.1. Not sure if this happened to the previous version but i believe this happens to all types of browsers

bradleyke commented 5 years ago

I observed the same leak. It looks like this is caused by the setup of the component

      setup: (editor: any) => {
        this.editor = editor;
        editor.on('init', (e: Event) => {
          this.initEditor(e, editor);
        });

        if (this.init && typeof this.init.setup === 'function') {
          this.init.setup(editor);
        }
      }

image

A reference to the editor is being kept in the closure and the settings object is cached on the tinymce global. Since the settings object contains setup, a reference to the editor is then kept on the tinymce global even after the editor is destroyed.

As a workaround in your own ngOnDestroy you can just null out the setup function on the global settings.

SimonFc commented 5 years ago

Thanks for reporting the issue! It turned out that this memory leak was due to a problem in TinyMCE. A fix for this will be out in TinyMCE 5.0.10.

NicolasFernandez212 commented 2 years ago

I have the save problem of memory leak of editor component , but my angular app is in version 8.2.6 so i have to install the latest version of tinymce-angular@^3.6.1 , in this tinymce-angular verison , tinymce version is 5.0.0.

How can i fix the memory leak for my angular v8.2.6 app ?

marfyl commented 2 years ago

Thanks for reporting the issue! It turned out that this memory leak was due to a problem in TinyMCE. A fix for this will be out in TinyMCE 5.0.10.

The problem is not solved in tinymce 5.X, It keeps causing memory leaks, a simple initialization and a destroy still reproduces the problem

DaSchTour commented 3 months ago

We can observe memory leaks that lead to crashes in Chrome with @tinymce/tinymce-angular: 8.0.0 and tinymce: 7.2.1.