Debugging memory issues

I’ve got a nasty memory leak somewhere. As I navigate around, memory grows rapidly causing the app to crash after a short period of use. I’ve gone through my code and so far haven’t found anything that I recognize as a potential cause for a memory leak, but I’m not used to debugging memory issues in JavaScript. So my questions - not necessarily strictly related to Ionic:

  • Any recommended resources or suggestions for debugging JS memory issues?
  • Is there anything specific with Ionic to keep in mind for memory use?
  • My app uses a side menu and a tabbed interface. The side menu is the same for all tabs. I’m using Angular, and I have separate controllers for all my views. There is one big service which holds common methods and data for all my controllers. I make heavy use of promises and thought perhaps the promises from the service to the controller might be throwing off the reference counter, but from what I’ve tested so far, that doesn’t seem to be the case, though I could be missing something.

Any tips from any of you on tracking down memory issues or plugging leaks when moving between views?

One thing that you may run into is that console.log/dir will retain whatever you are logging (at least in my testing on chrome/safari/ios). For example, if you are using console.dir to peek at a large object when developing/debugging, those will never get released. If you do this in a loop, or on every route change, etc, you can run out of memory pretty quickly while running on a device.

I have experience the same issue and I can confirm that it persist in the beta 6, here’s a link to the specific issue.

francoaa, thanks for the additional info. Looks like what I’m experiencing. I’m not yet convinced that it’s not something in my code, but I’ve gone through it and gone through it and can’t find sources of this kind of leaking.

My app includes map views which occupy a bit of memory; with the leak, it can’t be used long without crashing so this is something I really need to track down or my app isn’t terribly useful.