9

I am facing memory leak issue in angular js application. I have tried all the possible solutions like profile tool, timeline and some other tools related to angular js. My Work till now -

Profile Tool

In profile tool JS heap is keep on getting increased but can't able to find the reason for it. Detached dom element keep on increasing

Timeline

It shows there is a possibility of memory leaks but still I don't know how to debug and fix it.

enter image description here

Task Manager

It keep on increasing the memory size.Some time it is getting garbage collected but not significantly. enter image description here

Please let me know how to debug and find out what could be the issue.Or share your experience if you have faced the same issue.

11
  • 1
    can you post related code ? or any plunker wud be great ! along that can you do timeline profiling and expand the event tree log and check which function is eating memory Commented Sep 30, 2016 at 6:50
  • In addition to what @Angular_10 has said above, you can also try tools like Batarang to see what variables are in scope when this memory leak happens. This is really really common in AngularJS Commented Oct 4, 2016 at 6:36
  • Try to use as little $scope.$apply() as possible. Commented Oct 6, 2016 at 19:25
  • Can you write how you are creating instances of Person. do you use timers? also are you using ngRoute module? and last but not least do you have complicated event listening for the elements? Commented Oct 7, 2016 at 0:55
  • @Qaddura Yes, we are using ng state routers. Commented Oct 7, 2016 at 11:48

1 Answer 1

1

AngularJS has memory leaks when there are many bindings. Now limitation of angularJS is that it has 2-way binding. So, if you change any value in model, view that triggers $diget(), $watch() loop. So, depending upon how big your application is it consumes memory.

I suggest to try couple of steps:

  • Calculate angular Scope objects using angular batarang
  • Scopes $destroy() Method to free memory
  • Try to reduce your JS consumed in page. Use whatever is required

In my application I reduced watchers and life was easy.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.