Memory leak in state change
It appears that changing state increases memory usage with every transition. Here's a simple example. Open your browser's memory profiler and click "Get Clicky".
http://codepen.io/perrygovier/pen/FJgBa
Pages with more stuff on it tend to increase the amount of memory that gets eaten with each transition. Note the number of nodes and listeners never decreases.

On my app that uses a few larger lists, the app can quickly get to 200mb after just a few mins of manual clicking back and forth. I have yet to crash the app due to memory pressure, but it seems more a matter of impatience than something that wouldn't happen with continued use.
I believe this is less an issue with Ionic and more to do with Angular's UI Router, but I thought I'd start here as it's where it popped up for me.
https://github.com/angular-ui/ui-router/issues/545
There's a parallel discussion that lead to this ticket being opened. It appears other users are seeing what I am in where larger apps escalate quicker.
http://forum.ionicframework.com/t/memory-leak/2823/4
More interesting, Aritzg created an example in pure Angular, and while memory spiked, it was quickly garbage collected. I'll try to whip up a demo this weekend to confirm. Perhaps there's something Ionic's doing to prevent or limit that GC event?
I've done a bit more digging, but it's still a mystery what the root cause of the issue is. I ran some benchmarks against a plain UI Router example, matching the version Ionic is using. It does appear that the leak in ng-animate has been fixed.
This is code I used for these tests https://dl.dropboxusercontent.com/u/9006564/test.zip
First, without ng-animate

Then, with ng-animate

Note the immediate drop in memory after each page transition using ng-animate, that's to be expected. Both are reduced back to near their original size once the CG button is clicked at the end. The stepping in the first one was automatic GC before I was able to click the button.
It has been suggested on the UI Router github tickets, that the node and listener count perpetually increasing is actually a bug in web inspector, and can be ignored. Unfortunately, Safari and Firefox's inspector do not offer node or listener count to confirm this.
So UI Router may not be the sole cause of the leak. Taking a closer look at Ionic:
Here's a heap comparison (delta) going from the main page to another and back on the above UI Router demo, and the Ionic tabs demo.
Angular UI Router example
Here's the Ionic tabs demo

These lists can be pretty intimidating to sift through. Worth noting however, is that the node list has a zero delta in plain UI Router, and has grown by 2240 elements in Ionic. Now, after the first dashboard -> friends -> dashboard cycle, this could be just caching. However, this is after the third cycle, so I think the node delta should be 0.
More interesting are the elements in the Detached DOM Tree arrays. In it, I find markup from the previous pages. These detached DOM tree elements explain why having larger pages, large graphics, or video exacerbate the leak. I believe this is the primary culprit for the memory leaks that have gotten to be in the hundreds of MBs.

Upon selecting any element in this list, I believe things that show up in yellow in the window below, indicate a reference keeping them from being released. Many of these reference createEventHandler() of the jQLight library. As plain Angular uses this too, I'll have to think about next steps in tracking this down. Maybe set up a log for that method, and then cross reference the elements with the list of elements not being released.
The search continues.
Hope this was helpful.
TLDR: It looks like UI Router has fixed most of its problems, and the others are the inspector's fault. It appears that some event listeners aren't removed on state changes, keeping those old elements in memory even after they're removed from the DOM.
This is great, thanks for digging into this. So you said UI Router has fixed most of its problems, so do you mean its fixed its problems in version 0.2.7, or 0.2.10? Right now Ionic is using 0.2.7 because at the time 0.2.8 had bugs and we've been holding back and upgrading.
Hi. I have just updated to 1.0 beta.2 and replaced ui-router 0.2.7 with 0.2.10 but still the memory leak remains.
It currently is not leaking for me in Chrome 34.0.18 OSX, given the example in the OP and using ui-router 0.2.10 with the nightly build.
Here's a codepen with 0.2.10: http://codepen.io/ionic/pen/fa145096b86fc28c81006da84028e28e/
Still seeing a number of detached DOM trees, but only a single stray event listener, and the memory impact after initial caching and GC is negligible. Might be a good idea to test with more complicated templates, but it's looking good to me.
We should definitely get those stray event listeners then!
How can you tell with more clarity what is leaking? I don't really know how to use the memory profiler besides to look at the graph.
I will try to reproduce my case in CodePen. Until now, the bigger the dom objects were (say images, item lists with images), the bigger the memory leak was.
I don't understand it completely either, but in profiles, you can take multiple heap snapshots and then change from the summary view to the comparison view, seeing the changes in memory between two points. As you dig down, I'm not sure how to interpret everything, but I know detached DOM trees are DOM elements that are no longer in the DOM but are either waiting for GC or are being held on to by stray listeners or something similar.
After clicking through each page and populating the cache, it's my understanding there shouldn't be any additional detached DOM trees. Still, this is substantially less of a problem than it was.
I have just forked @ajoslin 's pen
http://codepen.io/aritzg/pen/beaFy
As you will notice, I added a fourth tab called 'list' which shows a 6 item list. each item has a name, a description and an image.
I you try the "get clicky" button and start a record (In Chrome ) Developer tools -> Timeline --> Memory , you will see used memory will grow. From time to time, GC will do its job but memory baseline will keep growing.
Regards!
Any update about this issue? Because I tried upgrading router-ui but the memory leaking persists
Working on it.
I just fixed a memory leak: scrollView was adding listeners to the document and never removing them.
There might still be more leaks, though.
Could you guys investigate with the newest nightly (once it's up, about 30 minutes after this post)?
Thanks all.
Cool! @graemefoster and I suspected this today while profiling our app. Good to see a fix has been put in. I'll give it a whirl later in the week and see what impact it has.
HI @ajoslin . First of all thanks for your efort.
I forked the codepen published before.
With 1.0.0 b3 http://codepen.io/aritzg/pen/oxdaf
With nightly http://codepen.io/aritzg/pen/ohFyq
I benchmarked both but unfortunately IMHO, the memory leak remains.
Here the results.

Blue marks refer to the moment when I click on "get licky". Grean mark refer to the moment when I force GC manually
I am java/web developer and not very skilled with JS so, by now, I can not offer much more help than this.
Hope this helps.
Regards
Hi @aritzg,
Thanks for the benchmarks.
We'll continue to look at this.
I'm seeing a pretty nasty leak that I assume is related. I've got an app with a side menu and four tabs. First tab contains a Mapbox embed. Switch between tabs and memory grows and grows. This is particularly pronounced with the mapbox view.
I've thrown together a Codepen with a similar structure showing the effect. The mapbox view is pretty basic with no pins and the other tabs are minimal so the memory growth is not much (though any leak should be plugged) but in my actual app it is quite serious, leading the app to crash after a short period of usage, rendering it essentially unusable.
http://codepen.io/thechrisroberts/pen/IowtF
The image below shows snapshots after the initial load, then switching to tab 2 and tab 3, then back to tab 1. Memory use inches up every step.

The next image shows the app I'm working on: initial load, switch to a couple of tabs, and switch back to the tab with the map.

Hi @thechrisroberts,
Thanks for the information. Does the mapbox have a 'destroy' or 'cleanup' method you can use?
For example:
var map = /* ... */
$scope.$on('$destroy', function() {
map.destroy();
});
It does, just updated the pen to use it. I experimented with that in my app and it didn't seem to make a difference but it looks like it does help in the pen. I'll look at it a bit more in my app.