ngView Major Memory Leak

1,451 views
Skip to first unread message

Michael Francis

unread,
Jun 7, 2013, 10:39:59 AM6/7/13
to ang...@googlegroups.com
I'm noticing a major memory leak when using ngView.  You can actually see it happening on the angular api. If you go there and switch back and forth between two pages you'll noticed that memory keeps going up and the page will eventually crash.

Scott Elcomb

unread,
Jun 7, 2013, 12:37:50 PM6/7/13
to ang...@googlegroups.com
I'm seeing the same. A quick search turned up
<http://stackoverflow.com/questions/16947957/how-does-angularjs-handle-memory-management-with-ngview>
so I've added a call to $templateCache.removeAll() in my
$routeChangeStart handler. That seemed to help a little, but didn't
completely fix it.

Checking now if pitfall #2 from
<http://thenittygritty.co/angularjs-pitfalls-using-scopes> is the
culprit in my app, I'd also appreciate any further advice on this
topic.

Best,
--
Scott Elcomb
@psema4 on Twitter / Identi.ca / Github & more

Atomic OS: Self Contained Microsystems
http://code.google.com/p/atomos/

Member of the Pirate Party of Canada
http://www.pirateparty.ca/
Message has been deleted

Michael Francis

unread,
Jun 7, 2013, 2:26:45 PM6/7/13
to ang...@googlegroups.com
That was actually my stack overflow question. I wanted to ask it before I went and claimed there was a memory leak.

I did the same thing with the $templateCache. And noticed the same thing. Drastically improved but did not eliminate the issue.

I was trying to see where exactly the templates were being stashed to see if it kept adding it to the cache even though the template was already cached.

I hope to look into this more over the weekend. This could be a stopper issue for any large scale application.

Andy Joslin

unread,
Jun 7, 2013, 6:47:34 PM6/7/13
to ang...@googlegroups.com
Are you sure you don't have some un-cleaned-up $scope-stuff happening in your controllers?

mark prades

unread,
Jun 8, 2013, 4:16:05 PM6/8/13
to ang...@googlegroups.com
just checked the API docs , indeed , there is a major issue here .

Stephane Le Dorze

unread,
Jun 8, 2013, 6:20:16 PM6/8/13
to ang...@googlegroups.com
Can you point out the relevant doc please?
Thanks

mark prades

unread,
Jun 8, 2013, 7:43:07 PM6/8/13
to ang...@googlegroups.com
go to the api docs and toggle between 2 links in the right menu : http://docs.angularjs.org/api/
fire the dev tools , timeline , record and the memory usage keeps on growing ( i got up to 300 meg ... )
BUT  , maybe it has nothing to do with AngularJS , it could  be the disqus widget that is leaky , i need to look into that.

Pawel Kozlowski

unread,
Jun 11, 2013, 7:11:08 AM6/11/13
to ang...@googlegroups.com
Hi!

On Sat, Jun 8, 2013 at 10:16 PM, mark prades <parais...@gmail.com> wrote:
> just checked the API docs , indeed , there is a major issue here .

Yes, there was a memory leak in the documentation site (not in the
framework itself).
It was fixed via
https://github.com/angular/angular.js/commit/6c663154943e4c0c33c19026a7b500302bda29d4

Cheers,
Pawel


--
AngularJS book:
http://www.packtpub.com/angularjs-web-application-development/book
Looking for bootstrap-based widget library for AngularJS?
http://angular-ui.github.com/bootstrap/
Reply all
Reply to author
Forward
0 new messages