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

Serious memory leak #26

Open
Ellisthion opened this issue Nov 29, 2015 · 1 comment
Open

Serious memory leak #26

Ellisthion opened this issue Nov 29, 2015 · 1 comment

Comments

@Ellisthion
Copy link

Due to a questionable feature in jQuery, the resize code causes a memory leak where it will hold on to every DOM node it has ever tracked. In a single-page application this can be a serious issue if you're creating and destroying things around the place.

jQuery has a strange feature where it keeps references to every state in a series of jQuery method calls, in a property called prevObject. If you keep jQuery references around for a while and do lots of stuff, they can amass a huge chain of prevObject references, preventing anything from being garbage collected. More information: http://blog.cowchimp.com/jquery-prevobject-memory-leak/

This resize library stores its tracked elements in a jQuery array (var elems = $([])), which is never disposed. It then uses mutating functions to add and remove elements. Unfortunately, due to the above jQuery feature, this means that any element that ever enters that elems collection will be retained indefinitely.

The solution is to replace the elems jQuery array with a normal Javascript array.

@martin-wintz
Copy link

I was just looking through forks of this library to see if anybody has fixed this and found this commit.

@meze, will you open a PR to this library?

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

2 participants