Edit: just wanted to add a TLDR - it would be nice if there was a blog post from the ionic team about managing memory in ionic apps! Thanks!
Hey everyone, I’m making good progress on my app and I’m quite happy with load times and responsiveness after making the shift to lazy loading, but now I’m trying to continue optimizing and my current goal is to reduce memory usage.
I’ve made some other posts on here about my app but basically it’s big - almost 250 pages big! Each of these pages has text, grids, and some pages have images. The grids all link to small (3 second) audio files that I’m loading, playing, and unloading with ionic nativeAudio.
I load my home page and base memory usage is around 200 megs, which is larger than I think is ideal but probably fine for most phones/tablets sold in the last few years. If it stayed around 200 megs I would be quite satisfied.
The problem is that for some reason memory usage creeps up as I go from page to page, following a pattern of two steps forward and one step back. I thought that ionic would automatically clear out old data/pages on ionViewDidLeave, but is there some sort of clearing command that I need to execute so that it doesn’t cache all of the old pages in the navigation stack into memory?
I am manually unloading all audio files on ionViewDidLeave(), but I can’t think of what else might be increasing memory usage. My app, though it has many pages, is pretty simple and I can’t imagine that the individual pages of text/grids are very resource intensive. CPU usage sits around 0-4% except with a small spike on page changes. I’m not using the network at all, everything is stored locally, and memory is the last optimization that I need to focus on.
Thanks in advance for any advice!