Skip to content
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

Closed
ryanackley opened this issue May 19, 2011 · 5 comments
Closed

Memory leaks when adding/removing the editor #254

ryanackley opened this issue May 19, 2011 · 5 comments
Assignees

Comments

@ryanackley
Copy link

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

@c-spencer
Copy link
Contributor

For reference, the offending setInterval is in ace/layer/text: Text.$pollSizeChanges().

@fjakobs
Copy link
Contributor

fjakobs commented May 20, 2011

Ace misses a dispose() function. Simply removing the DOM will not be enough. Partly because of the interval.

@ghost ghost assigned fjakobs May 20, 2011
@iebuggy
Copy link
Contributor

iebuggy commented May 25, 2011

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.

@fjakobs
Copy link
Contributor

fjakobs commented May 27, 2011

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.

@fjakobs
Copy link
Contributor

fjakobs commented Jul 23, 2011

close as duplicate of #344

@fjakobs fjakobs closed this as completed Jul 23, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants