-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
I am receiving a crash on Crashlytics with the following exception:
Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. mmap() failed: Out of memory size: 2147483648 offset: 0 in /Users/cm/Realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101
I understand this issue has been raised before a few times, however I have researched through all of the possible suggestions and cannot find a solution to this crash. This is an app in production for several years and this crash has only started to happen recently. It happens to less than 1% of my users but ironically it is only happening on one specific device - Samsung Galaxy Tab A SM-T510.
The crash seems to be happening on launch of the app, when trying to get an instance of Realm, rather than when trying to execute a transaction, or perform any other operation. The database size varies in different crashes, they are one of the following:
- 2147483648
- 2013265920
- 1476395008
- 1342177280
- 1207959552
Steps I have taken to try and solve:
- I have ensured all open instances of realm are closed as soon as I am finished with them
- I have checked that all transactions are not inside long loops
- I have attempted to migrate Realm to a new version, and delete all of the database
Actual Results
Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. mmap() failed: Out of memory size: 2147483648 offset: 0 in /Users/cm/Realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101 at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(OsSharedRealm.java) at io.realm.internal.OsSharedRealm.<init>(OsSharedRealm.java:171) at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:241) at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:231) at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:318) at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:284) at io.realm.Realm.getDefaultInstance(Realm.java:407) at com.myapp.android.app.MyApp.initializeIntercom(MyApp.java:215) at com.myapp.android.app.MyApp.onCreate(MyApp.java:117) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1158) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6272) at android.app.ActivityThread.access$1200(ActivityThread.java:240) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1796) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7100) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Steps & Code to Reproduce
I have been unable to reproduce this crash. I have also inflated Realm on my own device to 2.45GB by inserting dummy data, and have yet been unable to reproduce. I have detailed below the function in my Application class where the crash happens.
private void initializeIntercom() {
String intercomIdCheck = getString(R.string.intercom_api_id);
String intercomKeyCheck = getString(R.string.intercom_api_key);
if (intercomIdCheck.isEmpty() || intercomKeyCheck.isEmpty()) {
return;
}
Realm realm = null;
try {
realm = Realm.getDefaultInstance(); <------ LINE 215 where crash happens
User user = realm.where(User.class)
.equalTo("userId", datastore.getUserId())
.findFirst();
if (user != null &&
user.settings != null &&
user.settings.intercom_enabled == 1) {
Intercom.initialize(
this,
getString(R.string.intercom_api_key),
getString(R.string.intercom_api_id)
);
}
} catch (Exception ex) {
MyApp.logThrowable(ex);
} finally {
if (realm != null) {
realm.close();
}
}
}
Version of Realm and tooling
Realm version(s): 5.12.0
Realm Sync feature enabled: No
Android Studio version: 3.5.3
Android Build Tools version: 28
Gradle version: 5.4.1
Which Android version and device(s): Android 9 - Samsung Tab A SM-T510