Memory error iOS


#1

Hi, I have created an hybrid app using cordova 4.0 and ionic beta 13 . My app crashes on start on ipad with iOS 8.1 with a memory warning. Can anyone guide me direction for tracking the memory problem.

What I have tried:

  1. Increased the default Cordova cache memory.
  2. Remove image thumbnails.
  3. Check for cyclic assignment in javascript.

#2

Check memory usage of ram and flash?
Are you using splashscreens or are you writing data in localstorage or something else?


#3

For now splash screen is the cordova’s default one. And yes we are using localstorage to store some offline data which also includes image urls. do you think this could affect the memory. If yes them how to address this issue because localstorage is a crucial component in the app’s functionality.


#4

image urls does not hurt.

But how many data is in the localstorage?


#5

Ok so i have figured out what might be causing the issue. It maybe because of too many images on ion-content. We are creating a notification dashboard ( something like home screen of facebook ) which has cards on which there are images. Memory warning occurs whenever routed back to this screen or new card is added upon a pull to refresh.

Can you guide me in this regarding.

Thanks


#6

could you say more detailed about the images are shown… i do not know facebook homescreen.

If they are organized like lists -> use collection repeat to only hold the visible parts in dom.
Or put only images in the dom, which are in the viewport and fold the other (with ng-if).

Provide smaller images, if you only show thumbnails -> do not scale down big images by browser or css.
so if your card image has max dimensions of 400x400px store them in that dimensions.


#7

hmm… is there a way to find the scroll position of ion-content or to which dom element is in viewport in ionic so as to apply something called lazy-loading effect. By this way I would be able load image thumbnails when the respective card is in view.


#8

look in the documentation to get current scrollposition you can use the $ionicScrollDelegate service.
Maybe you can make a little calculation get document/window.clientWidth/height then you should get viewport height and width.

And if your cards have fixed with and height you can calculate the visible parts + 1 card above and below.


#9

Ok … Thanks for your help … :smile: