Skip to content

flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: IsarError: Cannot open Environment: MdbxError (12): Cannot allocate memory #1527

Open
@elite-kai

Description

@elite-kai

Hello, I have a problem here. When I run it on iphoneX, I get this error: Unhandled Exception: IsarError: Cannot open Environment: MdbxError (12): Cannot allocate memory. I have no problem running it on iPhone11 or above. I searched for relevant knowledge and found that the running memory of iPhone11 and above mobile phone models is 4G, and the running memory of iPhoneX is 3G. My application content is mainly related to data storage, and I need to store a lot of data, so I created 6 Isar instances for different scenarios, which resulted in the error Unhandled Exception: IsarError: Cannot open Environment: reported on iphoneX. MdbxError (12): Cannot allocate memory. But if I set the maxSize parameter to be smaller, for example, if several isars are set to 100, there will be no problem when running. What does maxSize mean? Does it mean setting the maximum running memory? If I set all maxSizes to 100, but the data I need to store may be several gigabytes in size, will there be a problem?

Activity

elite-kai

elite-kai commented on Jan 7, 2024

@elite-kai
Author

It seems that the maxSize parameter will be affected by the running memory of the mobile phone. If the mobile phone is relatively low-end and I create multiple isars to store different functional data, then this error MdbxError (12): Cannot allocate memory will be reported.

shahmirzali49

shahmirzali49 commented on Feb 16, 2024

@shahmirzali49

I have this issue too. maxSizeMiB: 3072000, changed to default Isar.defaultMaxSizeMiB it works.

lvyandev

lvyandev commented on Oct 25, 2024

@lvyandev

But the default size is already specified to Isar.defaultMaxSizeMiB if null, isn't it?

factory _IsarImpl.open({
    required List<IsarGeneratedSchema> schemas,
    required String name,
    required IsarEngine engine,
    required String directory,
    required int? maxSizeMiB,
    required String? encryptionKey,
    required CompactCondition? compactOnLaunch,
    String? library,
  }) {
    IsarCore._initialize(library: library);

    if (engine == IsarEngine.isar) {
      if (encryptionKey != null) {
        throw ArgumentError('Isar engine does not support encryption. Please '
            'set the engine to IsarEngine.sqlite.');
      }

      // look at this line
      maxSizeMiB ??= Isar.defaultMaxSizeMiB;
    } else {
      if (compactOnLaunch != null) {
        throw ArgumentError('SQLite engine does not support compaction.');
      }
      maxSizeMiB ??= 0;
    }
mars3142

mars3142 commented on Nov 6, 2024

@mars3142

I also wanted to know the meaning of the maxSize. Our size was set to number x and after a while we couldn't write data into the database.

So it could be related to the file size AND memory size. Which is completely wrong in my opinion. Why should the developer set a hard limit for a file size (it's not a log file, which should be limited)? We don't know how many data the user will save. It should grow as much as the device has internal storage.

And the observation, that low end devices will crash, seems to show, that the complete database is also in RAM (like redis or memcache). I don't need this behavior.

It always drills down to the question: what is maxSize for?

lvyandev

lvyandev commented on Nov 11, 2024

@lvyandev

I also wanted to know the meaning of the maxSize. Our size was set to number x and after a while we couldn't write data into the database.

So it could be related to the file size AND memory size. Which is completely wrong in my opinion. Why should the developer set a hard limit for a file size (it's not a log file, which should be limited)? We don't know how many data the user will save. It should grow as much as the device has internal storage.

And the observation, that low end devices will crash, seems to show, that the complete database is also in RAM (like redis or memcache). I don't need this behavior.

It always drills down to the question: what is maxSize for?

Agree, this should be a bug that needs to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mars3142@lvyandev@elite-kai@shahmirzali49

        Issue actions

          flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: IsarError: Cannot open Environment: MdbxError (12): Cannot allocate memory · Issue #1527 · isar/isar