-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Clean up grid on destruction #619
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
Clean up grid on destruction #619
Conversation
I confirm that this is a concern. Any chance that it will be pulled/merged? |
Yes, I just need to build and test this out. We could also squash those commits into one, but that's more housekeeping. |
I can squash and rebase to latest master later today. That's if no one is going to mind me disturbing anything they have checked out from this PR. |
Squashed and rebased, but don't seem to be able to push - my net's having a bad day. There are 2 unit tests failing for me but it looks like the same 2 are failing in master. |
- Removing window resize handlers on destruction - Stop watching from parent scope on destroy so we can hopefully let go of the grid - Added cleanup to avoid leaking grid through additions to the options object
Any hope for this patch to be included? I have a 30MB memory leak every time I change page in my app... Is there a known workaround for this kind of problem? |
I would like to request some advance with this patch too, it's really hitting the performance specially in ie. |
I plan on taking a look at this shortly. There's more places that event handlers need to be cleaned up. |
Great!! Thank you so much! I'm also hanging on to this patch :-) |
What's the minimum needed to reproduce this? Create two pages with ngRouter, both with grids and then swap back and forth between them a bunch? I should see memory use climb in the profiler? |
Yes, exactly. Basically every time the controller gets recreated along with the template there is a memory increase due to watches being redefined without clearing previous ones. |
I think that should be sufficient. Might be hard to spot unless you have a fairly large dataset in your grid, but I think it's leaving the whole grid DOM behind each time it is destroyed. When I wrote the pull req, it was leaking in window event handlers, and the initial data set if you keep it around. May have changed since though. |
Unfortunately it looks likes the leaks are still occurring. I'm using this plunker as a test bed: http://plnkr.co/edit/j4DHNd?p=preview I'm going to go through and try to add $destroy handlers to the rest of the places we bind and see if that helps any. |
Still leaking after adding a By doing heap snapshots after a single route change on that plunker I can see the count of ngGrid instances growing by one each time. Not sure why it isn't getting GC'ed. |
I don't know if it can help, but I found this post http://roubenmeschian.com/rubo/?p=51 |
I've spent the last few days trying to track this down and am stuck. It looks like ng-repeat itself leaks. You can find my issue here: For now I'm closing this as I've taken it as far as I can. If anyone can discover the actual source of these leaks then I'll happily reopen it. |
In my project the leak is present on firefox too. I can clearly see it watching the about:memory page and using the diff tool. |
@c0bra Well wouldn't at least some memory improvements be better than none? This is a major issue in our app and although ng-grid still leaks, this would certainly be better than nothing. |
@saebekassebil I didn't find any actual improvements in my testing. I'm not convinced that the root issue is actually IN ng-grid's code. If someone can demonstrably verify the root cause and provide a fix then I will happily merge it. |
Really problematic in my codebase aswell.. ng-grid is really leaky.. tried looking into it but hard to do when you have no knowledge of the codebase. |
FYI, as of version 3.2.9 the memory leak is still there. Edit: |
This is intended as a fix to #618. The grid leaks memory in a few places when it is destroyed.
Plunker demonstration of the problem is in the linked issue.