-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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 leaks when adding/removing the editor #254
Comments
For reference, the offending setInterval is in ace/layer/text: Text.$pollSizeChanges(). |
Ace misses a dispose() function. Simply removing the DOM will not be enough. Partly because of the interval. |
I was wondering how to remove/delete ACE instances. I need to be able to do this cleanly before I can proceed with my current project. My current project uses EditArea, which I want to replace with ACE. With EditArea, I learned the hard way that removing an instance isn't as easy as removing the DOM elements. Deleting DOM elements directly out from under an in-browser editor is a bad idea that usually results in Javascript errors or, in this case, memory leaks. Best to expose a function from the editor itself that knows how to clean itself up, which you seem to be working on. With EditArea, I discovered the delete_instance() function but that function didn't work in some browsers if I added an instance again later to an identically-named #id. Just something to keep in mind as you author dispose() is that some users might create and destroy instances multiple times on the same element id. EditArea also has hide() and show() methods, which is how I eventually worked around the bugs in delete_instance(). Exposing similar hide/show functions in ACE would also work for me. Without these sort of functions being exposed by most in-browser editors, directly hiding DOM elements is something I've also found to be buggy. |
Julian has added a destroy method in his split view commits. You should be able to simply call destroy on the editor and then remove the root element from the DOM. |
close as duplicate of #344 |
I have a project where I'm trying to integrate multiple editors on the same screen. I've noticed if I remove the dom component containing the editor, there is a memory leak. The associated Editor object never gets collected and the memory keeps growing.
Doing a heap dump in Google Chrome Canary dev tools, it looks like closures from TextInput are sticking around. Also, there is a call to setInterval that is never removed. This increases CPU usage when adding and removing editors
The text was updated successfully, but these errors were encountered: