-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Memory leak after creating and destroying the editor #5954
Comments
π |
Same problem over here. Next week we're going to try to make a dynamic Multi-root Editor, to see if we get an acceptable performance. |
Been there, done that. Under 75MB for a tab with tens of editable fields. |
Hello, Without collaboration feature, GC seems to remove instances but when I use the RealTimeCollaborativeEditing, objects accumulates on JS VM. And each time I load new document (destroy then create to load new document in CKEditor Cloud Services), it take more time than before to create editor. |
I did a quick scan today of the state of things and it looks like some of the memory leaks sources were removed from the time I've reported that. As for the integrations I didn't check but I would advise anyone to check if memory leaks comes from the editor itself or not. Any non-destroyed listener which touches edit: Also logging editor to the console and not clearing the console will also hold that editor instance in memory after the editor was destroyed. |
I don't know if I need to drop this here, but I used the (new?) builder at https://ckeditor.com/ckeditor-5/online-builder/ I've attached a super simple html page that managed to go to 40mb in JS memory on the first load and each page refresh easily adds 20mb, and it never goes down. Is there any way in JS to manually empty the memory or something like that? |
Hi @meddiecap! How did you test the memory consumption?Β I did a quick test with a similar setup and the results for page refreshing are as follow:
If the memory goes up/down on the page refresh it's up to the browser what it keeps in the memory and we can't control that. A full running editor will consume this much memory unfortunately. So this is how Chrome utilizes memory on page refresh and we can't control that. A memory leak would occur if you'd
And the memory after step 3 would be the same or significantly bigger than the memory after step 2. You can observe this below: |
Hey @jodator , thank you for your extensive explanation. I test the memory consumption by simply refreshing the page. Your first GIF shows me that you refresh the page a few times and then take a heap snapshot. Your second GIF gives me the impression that it is best to destroy all instances of ckeditor when, and just before, a user wants to leave or reload the page. (Or when new content is loaded via AJAX which will replace the ckeditor with a new one, which I also intend to do.) I tried just that and the snapshots do grow less, but still around 15mb per page reload:
|
this is preventing memory from being collected by the Garbage Collector during a page life cycle.
If you refresh the web page you get a clean state (so the previous JavaScript objects are removed). There is no need, at least to my knowledge, to clean the editors if a user simply leaves a page. If you plan to reload the editor on AJAX calls then using The +20 MB on every page refresh is very strange. On quick research, I've found one bug in Chrome (which might be unrelated to your case) so it could be possible that some other code is still retaining objects. However, the results you present in the GIF are curious - it looks like something might retain objects. The best way to verify memory leaks is to run the browser without any addons enabled:
You can compare snapshots between each other and inspect what happens there. But it might require some longer digging and staring into the I've used peek - it's Linux only tool. |
I watched the youtube video, very interesting. For now, when I leave the page, I loop over the editors and .destroy() them. Although I still get the memory spikes I mentioned before, it also seems to be related to the DevTools. I don't know well how to read all the data but with every page refresh it looked like the snapshot tool stored and extra 8 "ck" object / classes. Ckeditor was giving me console warning about missing toolbar stuff and fixing that also had some impact. When I don't use DevTools, the memory will go back down to much more acceptable levels after around 10 seconds. I learned a lot today |
It's possible to freeze the browser's tab after creating and destroying the editor multiple times (>100, it depends on the machine ). To reproduce the freeze, you can use our all features manual test. Simply try to create and destroy the editor ~200x. |
Apparently this is some very fresh bug because it doesn't seem to be reported yet. We need to wait now... |
OK, dev tools are still working. And I can confirm that there's some memory leak. Creating and destroying the editor, leaves 5MB of memory taken. The first snapshot before the editor creation, second when the editor is created, 3rd after destroying it and removing the reference from |
|
Hi. We are in touch with support team for a couple of weeks. They said they saw the leak 2 weeks ago. I leave a comment here. I am looking forward to see the solution really Thanks |
Hi @esezer! Thanks for your input. We've been investigating this problem and it looks like the memory retention by the
Can you run your test without the |
Hi @oleq! I created a new custom build editor without including MathType. But the problem is the same on my side. Details:
As result I don't see any toolbar icon for MathType but nothing changed for me. Should I try a different method? |
@esezer Can you share your sandbox online? |
@oleq I am sending you github url which I created CK team last month: This is the test url: https://merlon-test.firebaseapp.com/ I made tests all the day and found out an important memory leak on one of the CKEditor5 original plugins. Wiris plugin makes a memory leak really but it is not that much than the leak I found today. Tests show me that the most important leak is on "Table" plugins.
I tried several times with and without those plugins above and results were dramatically different. You can check out the repo on github to see my test project. |
I can confirm it on this sample: The spikes are new editors created. Pretty much none of them is cleared out. But there's still MathType used somewhere there: Please remove MathType and check then. The Table plugins may contribute to the size of the leak. But the most important question is β what causes the leak? From what we saw, it starts in MathType. Which means that it's the thing that needs to be fixed. But of course we may be wrong, so it'd be awesome if you could modify this sample to remove MathType and check again. |
I had already tried sample with and without MathType. But this time inside "ckeditor5-build-classic";
I copied the build folder into my test application and built it. Then deployed the test app to the same url. I also pushed the changes to my test repo. When I start the test it still freezes and even sometimes crashes before finish. You can test the url and check the repo. But if I also remove table plugins together with MathType, then it works much better. That's why I thought it could be a leak because of table plugins. Because the only difference is that. Thank you for your support. |
Cross-positing the update from Wiris (the company behind
|
π Provide detailed reproduction steps (if any)
βοΈ Expected result
No editor in the memory.
β Actual result
There is an editor left in the memory
π Other details
Performance time line:
There's ClassicEditor in the memory:
And some detached event listeners:
If you'd like to see this fixed sooner, add a π reaction to this post.
The text was updated successfully, but these errors were encountered: