Memory Leaks

Thanks for a fantastic project, we feel ionic is by far the best hybrid platform available. We have used the platform in our apps; however, cordova / ionic / angular stability issues challenges our ability to quickly deploy and scale apps. To be clear, it is more important for us to have a stable platform, than more features (e.g., Ionic Creator).

One serious issue we’ve encountered are DOM node and memory leaks. We have verified this using ionic beta10, beta11 and the latest nightly build (ionic-bower#1.0.0-beta.12-nightly-482) running the xcode activity monitor instrument. Unfortunately we can’t pinpoint the exact cause, and unsure if Cordova, Angular, or Ionic is the culprit; however, it does seem to be worse when running on an iPhone compared to Google Chrome (Mac).

All of our Ionic ios apps leak nodes and memory, and the other ionic ios apps in the Apple store leak memory as well. To demonstrate, I downloaded a Drifty app that uses beta10. By switching back and forth between tabs for 7 minutes, the app crashes, as it exceeds 600 MB of RAM threshold set by ios.

Here is the video showing how the drifty’s app “HN Front Page” memory grows until the crash (video shown at 2x speed):

I know these issues have been reviewed before, but it looks like not completely fixed.

Any help uncovering this issue would be appreciated. Thanks, Steve


HN Front Page App:


2 Likes

I submitted app to Apple Store based on ionicFramework beta 12. They rejected the app because of memory leaks. Could this be related? I need help ASAP, as I don’t know how to respond to Apple. I don’t know how to check or fix the memory leaks. Can someone please help this issue?

OMG 600 mb in ram? O.o this is so weird… On windows machine, ( and then Adnroid ofcourse ) I haven’t this memory leaks … sorry but in iOS i’m completely noob :frowning:

Hope you guys recieve help form some of ionic team,

Good luck and sorry again.

Did you try to reopen the issue?

+1 to reopen and fix asap - am going to push apps to app store shortly

@darrenahunter:

1. It is not certain the issue @camtera is reporting is in fact due to all apps built with Ionic, or a specific implementation that they are using. I have never had memory issues to speak of with my Ionic apps, and I have already succesfully submitted 5 apps to the iTunes store. That doesn’t mean they don’t exist, it just means further research is required.

So are you experiencing memory issues yourself with your app?

2. If so, why don’t you go to the GitHub and actually add to the discussion on that issue? Just saying here ‘open the issue’ won’t make it so.

@darrenahunter
Thanks for the feedback. I downloaded your Southern Cosmetics app (nicely done!) to understand how your implementation is not leaking.

But unfortunately I see your app leaking as well – it crashed after 7 minutes of continuous tapping in your tab navigation, consuming more than 500MB (very similar to the video above). I’m using an iPhone 5s running iOS7.1.2.

Here is the screenshot of your app memory usage before it crashed:

I will do more research and reopen the memory issue.

https://itunes.apple.com/us/app/southern-cosmetics/id890712690?ls=1&mt=

thanks @coen_warmer for your in site - very helpful

there is plenty of mounting evidence we have an issue here - yes it may not be ionic but it is still an important issue if we can’t push our ionic apps to the app store due to memory usage.

so many talented people in this community especially the ionic guru’s that re raising this issue is important - so we get many eyes on it

and congrats on push 5 apps to the app store. doesn’t mean they don’t have memory leaks as @camtera pointed out with one of my apps accepted into the app store.

looking forward to your input on this too

Hi @camtera

The Southern Cosmetics app is actually one I did. Thanks for taking the time to have a look at it.
Does the leak only come from switching tabs or also navigating via the sidemenu.

I will try and spend sometime today on this. I recall I viewed a very good Addy Osmani video on memory management and using chrome devtools to dig deeper. see link http://addyosmani.com/blog/video-javascript-memory-management-masterclass/

cheers
Darren

Darren, I edited my post, thanks. I only tested your app switching betweens tabs.

When troubleshooting and researching this, the issue seem more significant in iOS than Chrome. This might be related to UIWebView problems, or Chrome’s approach to garbage collection.

wonder how it goes with the new WKWebView in iOS8 - I don’t have it installed as yet or an iPhone 6

I’m having the exact same issue with tabs on iOS. If the content of the tab is large, the problem is really bad.

As a side note, I also very much agree that ionic’s success will be determined by the work they put into the framework rather than all the extra services. The framework is awesome, but is not robust. It doesn’t help developers with large amounts of data very well. Ex. collection-repeat is a great concept but javascript scrolling is slow and buggy on most android phones that it really forces a developer to choose between a long render wait or a very sluggish scroll.

I’m having this issue as well.
When calling a route, I remove my objects, clear $timeout and $interval, call $ionicHistory.clearCache().
But the issue is still here and my app becomes unstable after a moment.
I don’t know what else I can clear at this point. I really believe it’s an Ionic issue and not an AngularJs issue.

Silly question - what do u use to take those measurments in the video?

Memory Monitor, part of Xcode Instruments

more info:
https://developer.apple.com/library/ios/documentation/AnalysisTools/Reference/Instruments_User_Reference/MemoryMonitorInstrument/MemoryMonitorInstrument.html

I was having these huge memory leaks as well in iOS 8 only. Switching over to WKWebView instantly eliminated these for me: https://github.com/Telerik-Verified-Plugins/WKWebView

Pay special attention to the limitations of WKWebView which might not make it ideal for every app.

anyone from the ionic staff can comment over this subject??

i know no normal user will change as many page’s as he did in the first minute of the video…
(although if i had native-inline or banner ads on each page i would no complain xP; 1k users = 100k+ view’s)

anyway…
i guess the user will need reset the app always, i mean he can’t use as a background app with push notification, he will need close and open for use each day… and if depend’s on the loaded page size it sounds like can get much worse, with large images and videos…

this still a issue?? they know where is the bottleneck(angular, ionic, other js libraries or others sources)??

This is being discussed in ticket #1096 on Github https://github.com/driftyco/ionic/issues/1096#ref-issue-40172100

Is there any fix? I have this problem too.