-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Memory leak with nested ng-repeats #2624
Comments
Update: After discovering the 'show hidden properties' option in the profiler, I think i've traced the issue back to dangling references retained by angular's jqCache object. I'm not sure exactly why this is occurring though. |
Upon even further investigation, the problem disappears (with or without the code I added to $new) when chrome is run with
So it seems its definitely a bug with v8's maps being retained by optimized code. It looks like this patch in V8 may address the issue: https://code.google.com/p/v8/source/detail?r=13666 |
…extent that it can be without a patch to v8)
See also discussion on this PR: #2646 |
As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months. Please try the newest versions of Angular ( Thanks! |
Still exist in 1.0.8 and 1.2.0-rc.2... nested "ng-repeat" cause dramatic memory grow (DOM elements are not releasing). My app eats 70 megs per view change :( I got "ng-repeat" of directive with "ng-repeat" inside (list of products with their variations). tested on: IE, Safary, FF - ok |
I also discovered today that this was seriously impacting my end to end tests. I have been using the hack in my PR in my copy of angular, but I hadn't applied it in angular-scenario, which has its own instance of the scope code. Some of my larger e2e tests allocated upwards of 100mb that never got released, and was having serious negative impacts on performance. Applying the fix in my PR resolves this. I know its a hack, but since it doesn't seem to be a priority for the v8 team to fix this it seems like it might be worthwhile, as the negative impact is pretty significant in some cases. |
angular 1.2.0-rc.3 - problem is present. How to use Angular in production if he crashed chrome constantly... |
@ashaffer @btford
|
@ashaffer the v8 bug that was causing this leak is now fixed. I'm going to close this issue. if you still see mem leaks, please open a new issue with a link to plunker/jsfiddle app that reproduces the leak. |
This bug is a little strange, and i'm not sure whether angular is to blame or V8. I think ultimately its V8's issue, but there may or may not be things angular can do to mitigate it.
I've created a plunkr to demonstrate:
http://plnkr.co/edit/0xtIMLnl08h5BjGVDNug?p=preview
Let it run through its changes (should take only a few seconds), and then take a heap snapshot. Search for the 'Child' constructor and you should find that there are substantially more objects hanging around than there should be.
If you expand the Child objects list you should see most of them highlighted in yellow and some not highlighted at all - the un-highlighted ones are the ones that have been$destroy'd but are for some reason still resident in memory. You can check this by hovering over one and noting that $ $destroyed is set to true on all of them. Note in their retention trees the reference to 'prototype' inside of $new. I can eliminate all of the references in their retention trees without modifications to angular except this one.
I have written a quasi-fix for this that is commented out currently in the plunkr. If you comment back in my replacement for $new (at the top of the file) and let it run again, then you should see that something similar happens, but hopefully with somewhat fewer extraneous scopes hanging around. However, for the few that are left, if you examine their retention trees they will be empty, which leads me to believe that this is a bug in V8's garbage collector.
This is as far as i've been able to get with it on my own. I'm not sure if there is some hack to force V8 to garbage collect these or if we'll just have to wait for them to fix it.
I'm happy to send a pull request with my fix, but I don't really feel confident that its right or that it fully addresses the issue, so I thought it would be better to submit this as an issue first to see what you guys think.
Edit: I should point out that I have seen this happen on a single un-nested ng-repeat, but I wasn't able to create a toy example to reproduce that.
The text was updated successfully, but these errors were encountered: