Burst of memory - Flutter

Asked

Viewed 75 times

-2

While trying to unzip a 500MB zip file using the package Archive, I’m having memory problems (Out of memory).

Follow the code for evaluation and suggestion of some alternative.

    unarchiveAndSave(var zippedFile) async {
    var bytes = zippedFile.readAsBytesSync();
    var archive = ZipDecoder().decodeBytes(bytes);

    for (var file in archive) {
      var fileName = '$_dir/${file.name}';

      if (file.isFile) {
        var outFile = File(fileName);
        print('File:: ${outFile.path}');
        outFile = await outFile.create(recursive: true);
        await outFile.writeAsBytes(file.content);
      }
    }
  }

The system decompresses much of the file, however, at some point the return I have is that lost the connection with the emulator and other Out of memory.

  • 2

    Have you tried the physical device?

  • Yeah, same thing happens. As this was not working, I changed the approach a little and I’m using the package Cachednetworkplugin, which already makes even handling errors when I download the files on the Internet. Before the approach was to download a compressed file with all the photos, now I’m reading the photos directly from the site. Thank you

1 answer

1

  • I’m tempted to think that’s true or close to it, but the way it is, it doesn’t seem terribly useful. It sounds more like a comment than a response. It’s been almost 1 day since this was posted, has how to test now to be able to elaborate better?

  • I will try this approach later. At the moment I found an alternative to get around it. Thanks for the help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.