brendan-duncan/archive

Out of Memory

Opened this issue · 1 comments

flutter: 3.7.7

My zip is 540KB and I get OOM when decrypting

E/flutter ( 5458): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Out of Memory
E/flutter ( 5458): #0      new Uint8List (dart:typed_data-patch/typed_data_patch.dart:2245:3)
E/flutter ( 5458): #1      OutputStream._expandBuffer (package:archive/src/util/output_stream.dart:149:23)
E/flutter ( 5458): #2      Inflate._decodeHuffman (package:archive/src/zlib/inflate.dart:292:16)
E/flutter ( 5458): #3      Inflate._parseDynamicHuffmanBlock (package:archive/src/zlib/inflate.dart:274:12)
E/flutter ( 5458): #4      Inflate._parseBlock (package:archive/src/zlib/inflate.dart:124:13)
E/flutter ( 5458): #5      Inflate._inflate (package:archive/src/zlib/inflate.dart:91:12)
E/flutter ( 5458): #6      new Inflate.buffer (package:archive/src/zlib/inflate.dart:21:5)
E/flutter ( 5458): #7      ZipFile.content (package:archive/src/zip/zip_file.dart:139:28)
E/flutter ( 5458): #8      ArchiveFile.content (package:archive/src/archive_file.dart:136:27)

My code

Future<void> unzip() async {
    final ByteData zip = await rootBundle.load("assets/config.zip");
    var bytes = zip.buffer.asUint8List(zip.offsetInBytes, zip.lengthInBytes);
    var archive = ZipDecoder().decodeBytes(bytes, password: "password");
    for (var file in archive) {
      if (file.isFile) {
        if (file.name.endsWith('.ini')) {
          
          final content = utf8.decode(file.content);
          final lines = LineSplitter.split(content);
          
          for (final line in lines) {
            Log.i(line);
          }
        }
      }
    }
  }

same issue here in android when i zip large file something size 200 mb