Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I check for garbage Observables in DevTools?

Tags:

In a pursue to avoid memory leaks, how do I specifically examine an Angular app against garbage Observables (those that have not been unsubscribed from)?

like image 299
user776686 Avatar asked May 10 '17 08:05

user776686


1 Answers

I don't think this is possible - such a mechanism would require a central store of all Observable - which in turn would again be a huge risk for memory leaks.

Suggestion #1

Try searching in your project for all uses of .subscribe and then check if each result contains a mechanism to unsubscribe at some point. Any manual .subscribe should have some mechanism of unsubscribing.

Suggestion #2

Use the DevTools to create memory-/heap-snapshots over time, if neither the memory nor the object-count goes up over time, while using the app, you can be fairly certain that memory leaks are not an issue for your application. I will not go in to detail on how to use the DevTools here, because that would be "slightly" out of scope, but have a look at this link (for the Chrome DevTools): https://developers.google.com/web/tools/chrome-devtools/memory-problems/ (in case the link becomes unavailable at any time, just google "how to use chrome developer tools heap snapshot")

like image 197
olsn Avatar answered Sep 21 '22 11:09

olsn