ericwoodruff / passwordhasherplus

Password Hasher Plus
http://goo.gl/LyLk3
Other
12 stars 21 forks source link

Memory Leak in Angular Apps #31

Open taylor1791 opened 9 years ago

taylor1791 commented 9 years ago

I was debugging a memory leak in my angular app and I noticed that passwordhasherplus was the cause. I know how to fix it in an angular app, but I am unsure if it will effect other SPAs. I can make a RP with the angular fix if you like.

ericwoodruff commented 9 years ago

Can you provide some more details? Why is your fix angular specific? On Aug 24, 2015 17:05, "Taylor Everding" notifications@github.com wrote:

I was debugging a memory leak in my angular app and I noticed that passwordhasherplus was the cause. I know how to fix it in an angular app, but I am unsure if it will effect other SPAs. I can make a RP with the angular fix if you like.

— Reply to this email directly or view it on GitHub https://github.com/ericwoodruff/passwordhasherplus/issues/31.

taylor1791 commented 9 years ago

After reading my first post, it was pretty badly constructed. Sorry about that. This is actually a bug in qtip, but the author doesn't seam to be interested in fixing it.

Here is a reproducible example. Open (Chrome) Timeline, and click start, then the trash icon to garbage collect. Click the toggle button 20-30 times, garbage collect, and stop the timeline. Here is the results. passhash-ml

The listeners and nodes increase each time the input shows.

In an angular application we would do something like this. However, I don't think this will work in a chrome extension.

var elem = angular.element(passwordInputElement)
elem.on('$destroy', function(){
  elem.unbind()
});

The most important thing is that elem.unbind() is called to remove any and all event listeners added by qtip or anything else. We could probably track down the exact the exact events so that we don't accidentally clobber events from other libraries.