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)?
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With