Possible memory leak when using ng-repeat inside directive in ng-view

1,171 views
Skip to first unread message

Michal Kurtak

unread,
Sep 15, 2013, 11:31:12 AM9/15/13
to ang...@googlegroups.com
Hi,

I have found memory leak when using ng-view with directive with ng-repeat in it. I believe it is a bug in angular 1.0.8 and 1.2.0.rc2. Here is a sample code http://plnkr.co/5adwl9kwCyxT5urU9D5x

Bug occures when switching between views:
view1 - view with directive nievents (ng-repeat inside it)
view2 - empty view

After switching between views several times, i can see Detached DOM tree (with 692 entries) with elements from view1, although i am switched to view2. When you keep switching again and again, copies of Detached DOM trees are created and cause memory leak.

I am not able to determine what causes a memory leak, but I can see ng-repeat scopes are not destroyed (parent scopes from controller are destroyed).

Tested on Chrome 29.0.1547.66 m but FF is also leaking.

Anyone else encountered the same issue?

Cheers,
Michal

Michal Kurtak

unread,
Sep 16, 2013, 9:47:03 AM9/16/13
to ang...@googlegroups.com
I took a screenshot of heap dump made in Chrome. It demonstrates memory leak i mentioned

Cheers,
Michal


Dňa nedeľa, 15. septembra 2013 17:31:12 UTC+2 Michal Kurtak napísal(-a):
angularjs-heap-dump.png

Nuno Mota

unread,
Oct 7, 2013, 7:20:40 AM10/7/13
to ang...@googlegroups.com
Hi.
I have the same issue :(:

OpenNota

unread,
Oct 7, 2013, 8:06:41 AM10/7/13
to ang...@googlegroups.com
I have some detached trees, too, but their number seem to remain the same, no matter how many times I switch views.

Peter McKee

unread,
Nov 12, 2013, 4:32:08 PM11/12/13
to ang...@googlegroups.com
I'm seeing the same thing ... any work around?

It looks like ngRepeat will use a "cache" for the elements placed in the dom if the object that is reference to it is still in the collection being watched by the ngRepeat.

But if compile is run again on ngRepeat, then the "cache" is wiped and the dom elements are orphaned. I also think that jQuery, at least in my case, is holding on to them.

Patrick Scanlon

unread,
Jan 27, 2014, 11:02:24 AM1/27/14
to ang...@googlegroups.com
Has Anyone figured this out? It seems to still be happening with angular 1.2.9

i have ng-repeat in a template for a directive. cant figure out how to stop this leak for the life of me!

Karel-Jan Van Haute

unread,
Sep 4, 2014, 6:02:19 AM9/4/14
to ang...@googlegroups.com
I'm having the same problem. Does someone has a solution for this?
Reply all
Reply to author
Forward
0 new messages