Ionic Save large file @Capacitor/filesystem – Out of memory error


I try to store multiple files in the file storage by using the @Capacitor/filesystem Plugin.

On large files I’m facing the following error – testet on my One Plus Pro 8 (Android 12):

W/System.err: java.lang.OutOfMemoryError: Failed to allocate a 150994952 byte allocation with 25165824 free bytes and 140MB until OOM, target footprint 280973616, growth limit 402653184

Code for saving the files:

        data: file.base64,
        directory: Directory.Data,
        recursive: true

Project configuration:


   Ionic CLI                     : 6.19.0 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 6.0.8
   @angular-devkit/build-angular : 13.0.4
   @angular-devkit/schematics    : 13.0.4
   @angular/cli                  : 13.0.4
   @ionic/angular-toolkit        : 5.0.3


   Capacitor CLI      : 3.4.1
   @capacitor/android : 3.4.1
   @capacitor/core    : 3.4.1
   @capacitor/ios     : not installed


   cordova-res : not installed globally
   native-run  : 1.5.0


I found the following package wich solved my problem:


It splits the file into multiple parts if it’s to low.

Answered By – maxi hraschan

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published