Memory leak with nested ng-repeats #2624
Description
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
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.