ionic-framework: Ionic 3.1.1 MAJOR MEMORY LEAK in the most basic ionic 3 app.

Ionic version: (check one with “x”) [X ] 3.1.1 running on iOS10

I’m submitting a … (check one with “x”) [X ] bug report

Current behavior: Scrolling creates a terrible memory leak.

Expected behavior: Memory should be released after scrolling.

Steps to reproduce:

ionic start scrollingtest blank

The ONLY modification made thereafter was to add 10 paragraphs to the “home” page in src/pages/home/home.html, outlined below, albeit im only going to show 1 paragraph here:

<ion-content padding>
  The world is your oyster.
  <p>
    If you get lost, the <a href="http://ionicframework.com/docs/v2">docs</a> will be your guide.
  </p>
  <p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent convallis nisi at metus auctor, nec egestas mauris vestibulum. Curabitur id pretium massa. Vestibulum maximus sagittis imperdiet. Cras pretium dui a dolor scelerisque iaculis. Fusce convallis velit in mi ultrices, ac imperdiet arcu pulvinar. Sed ornare luctus nulla a suscipit. Praesent pulvinar quis quam ac tristique. Vivamus id nibh sed risus tincidunt hendrerit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse egestas sapien quis orci tempor finibus.
  </p>

<!-- note, i added the same paragraph 10 times in-order to test scrolling, just seems redundant to paste them all in this issue report -->

ok … then run: ionic build --prod

Then open the ios app in xcode, and test run it on an actual device running iOS 10.

The app loads and displays the “home” page.

While running, select the “debug navigator” tab, and then select “memory” to monitor memory usage.

Next, just scroll the page up and then down continuously and it adds approximately ~1.5mb of memory usage with every scroll.

That memory is NEVER released after scrolling has ended. Eventually the app will crash due to this issue.

Screen shot attached after scrolling up then down, then up etc etc approximately 30 times: test

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Cordova CLI: 6.5.0 
Ionic Framework Version: 3.1.1
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.7
ios-deploy version: 1.9.1 
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v7.9.0
Xcode version: Xcode 8.3 Build version 8W120l

Note, i have tried a further test with the new WKWebView vs the UIWebView, and while initial memory usage is much lower, the memory increases during scrolling still persist.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 18 (5 by maintainers)

Most upvoted comments

@gitdisrupt Unfortunately we have not been able to reproduce this issue on our end. Would you mind checking your app on your device with safari dev tools instead of the memory tool in xcode? The reason I recommend this is because the xcode memory tools can be misleading in the fact that it’s not actually measuring memory usage of the javascript heap of the app, instead, it is reading the memory used by the kernel / OS itself. So based off the same concept I described here, the OS will not free up memory used by the JS virtual machine if it 1. thinks the action that used that memory is going to happen often and 2. thinks that it has plenty of memory to spare. So, while the JS heap memory will be shrinking every time the JS engine runs garbage collection, that does not mean that the memory that iOS has allocated to the browser will shrink, and, if iOS did start freeing up memory when it has plenty of memory available you would actually see performance issues. Also, it’s important to remember that high memory usage does not === a memory leak and in fact operating systems are built to take the most advantage of the resources (in this case ram) available to it, especially on mobile devices.

Ok so i can accept your note about XCode tools not really being the best for profiling a hybrid app, but as it related to this issue, there is no doubt a problem that still persists unfortunately.

After building and running the example above, and scrolling continuously for about an hour, the app crashes with the error: Terminated due to memory issue

I do not agree that this issue should be closed.

Any further info on this?

I was very careful not to change anything other than to add the paragraphs like noted above. The rest of all the code was generated by the ionic CLI… and still i see a huge memory problem.

Apple will most likely reject the app because of this problem.