Android data storage keep growing

Hi Guys,

I am new to ionic. Last week i have published my app to android play store. here is some details:

  1. App similar to Instagram (Load image and user can like the image)
  2. I am using LokiJs as data storage
  3. Crosswalk browser to improve the performance a lot,

But after sometimes, i realize that the data storage of the app grow quite fast, from 0MB to about > 100mb in a day. I did some testing by navigate from tab to tab, it looks like everytime i navigate, data storage will increase. Is it normal? anyone have any idea with this behaviour? let me know if need more information.

Thanks

bump. I have the same question.

Even after force quitting the app, the Data is not cleared and will increase further.
Our app also works with lots of images and therefore I think there is some cache mechanism. Maybe coming from Ionic or even crosswalk…

anyone got any hints?

came across this: http://stackoverflow.com/questions/9146425/android-app-data-storage-keeps-increasing

if this is really the reason then it looks to me that this should be in the cordova core - or at least a plugin?!

1 Like

I have seen the same too when using crosswalk, the standard droid webview seems to not exhibit the problem. Kind of rough seeing as using crosswalk fixes issues with app functionality and then shoots the older device in the head by filling storage pretty rapidly.

Will try the onpause fix zwacky linked at some point.

PS using crosswalk 13.42.319.6

Hi @zwacky

have tried ur solution, i added the code at:
CordovaActivity.java
/**

  • Called when the system is about to start resuming a previous activity.
    */
    @Override
    protected void onPause() {
    super.onPause();
    LOG.d(TAG, “Paused the activity.”);

    if (this.appView != null) {
    // CB-9382 If there is an activity that started for result and main activity is waiting for callback
    // result, we shoudn’t stop WebView Javascript timers, as activity for result might be using them
    boolean keepRunning = this.keepRunning || this.cordovaInterface.activityResultCallback != null;
    this.appView.handlePause(keepRunning);

     this.appView.clearCache(true);
    

    }
    }

tried with few android devices 4.4 and 5.0 and working fine so far, data stop growing like mad.

Thanks

2 Likes

i wonder what the downside of this is and why the cordova team hasn’t built it into cordova by default…

I stumbled upon this config.xml preference:

<preference name="xwalkCommandLine" value="--disk-cache-size=1024'" />

this might do the trick as well without native plugins.
related: https://github.com/driftyco/ionic/issues/3730#issuecomment-173954972

1 Like

looks like better solutions, let me try it out

thanks man

I tried it and it did work for me

hi @zwacky

i just checked my config.xml, currently there is default , so basically just replace this value right? not to add a new line

Thanks

you can have several xwalkCommandLine entries. I also have 2:

<preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect"/>
<preference name="xwalkCommandLine" value="--disk-cache-size=1024"/>

Hi Zwacky,

Alright!, thank you very much for your help