driftyco/ionic — pull request #2030 by jbasinger (2014-08-19 13:22:41+00:00)
Title: Almost got all the memory leaks!

I think I found most of the retaining references for issue #1993. I have a bunch of screenshots showing the retaining list shrinking after each commit, but it seems excessive to post them here. I got the list down to 5 items retaining the scroll view. The final ones **seem** to be with the self.mouse* and self.touch* events being added and removed in the js/views/scrollView.js file. When I highlight the retaining view function holding references I get information about jqLite's createEventHandler function. Setting all those events to angular.noop seemed to help remove a bit, but there is still a reference that I am having trouble finding. Here is a screenshot showing what I've found:

![5-retainers_jqlite](https://cloud.githubusercontent.com/assets/870614/3966405/b8a7eb04-27a2-11e4-9850-58dbb7607323.png)

In the interest of being transparent, I'm not quite sure how to write tests for memory leaks so there are none for this PR. If you can guide me how to do it, I'd be more than happy to do so. Also, I was able to run Karma and everything passed, but I'm having trouble getting the e2e tests to run so I'm not sure if I broke anything there.

So, long story longer, my theory is that something is using jqLite's createEventHandler function and not letting go of the scrollView when it's done. @ajoslin, does this spark any other ideas of what could be hanging on for dear life?