realm-java icon indicating copy to clipboard operation
realm-java copied to clipboard

Realm (10.0.0) crash after Unrecoverable error. mmap() failed: Out of memory size:

Open pvsilvestrin opened this issue 6 years ago • 5 comments

Goal

A weird crash is happening after I updated the app with Realm 10.0.0.

Actual Results

I don't know why, but firebase crashlytics is not detecting this crash so I do not have a good stack trace. This is the only trace I have from the crash that is from google play console vitals:

backtrace: #00 pc 000000000001a41a /system/lib/libc.so (abort+63) #00 pc 000000000020acf7 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 000000000020ad4d /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 000000000020ae47 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000001a709d /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000001a6fab /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000001bbdd9 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 0000000000164273 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000001db9d3 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 000000000015f92d /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000001cc765 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000001cb701 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000001cc939 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000001cd033 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000000aeda1 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000000adb61 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000000ad4d9 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so #00 pc 00000000000ec665 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/lib/arm/librealm-jni.so (Java_io_realm_internal_objectstore_OsObjectBuilder_nativeCreateOrUpdateTopLevelObject+216) #00 pc 00000000000621c9 /data/app/com.aegro.aegroapp-L0tVDr0GY_gHd2baULIzHg==/oat/arm/base.odex (offset 0x61000)

Steps & Code to Reproduce

I was not able to reproduce the crash.

Version of Realm and tooling

Realm version(s): 10.0.0

Realm Sync feature enabled: No

Android Studio version: 4.0

Android Build Tools version: 29.0.2

Gradle version: 6.1.1

Which Android version and device(s): Samsung Galaxy J7 Prime and Motorola Moto G Plus (5th Gen) Android 8.1 (SDK 27)

pvsilvestrin avatar Oct 30 '20 13:10 pvsilvestrin

After a lot of exploration I finally found the root cause of this error.

The first access in the app a good amount of data is downloaded and a bunch of writing realm transactions are performed. In devices with low ram memory, after some writing transactions, more than 300, realm throws this exception:

Caused by: io.realm.exceptions.RealmError: Unrecoverable error. mmap() failed: Out of memory size: 62734336 offset: 67108864 in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 143
        at io.realm.internal.OsSharedRealm.nativeCommitTransaction(Native Method)
        at io.realm.internal.OsSharedRealm.commitTransaction(OsSharedRealm.java:280)
        at io.realm.BaseRealm.commitTransaction(BaseRealm.java:447)
        at io.realm.Realm.commitTransaction(Realm.java:136)

After this exception, every time a new writing transaction is started this error happens:

2020-11-04 10:29:00.187 22037-22150/com.aegro.aegroapp E/REALM: ../src/realm/alloc_slab.cpp:526: [realm-core-10.0.0] Assertion failed: ref + size <= next->first with (ref, size, next->first, next->second, get_file_path_for_assertions()) =  [3027368, 8008, 3027368, 15976, "/data/user/0/com.aegro.aegroapp/files/default.realm"]
    <backtrace not supported on this platform>!!! IMPORTANT: Please send this log and info about Realm SDK version and other relevant reproduction info to [email protected].
2020-11-04 10:29:00.187 22037-22150/com.aegro.aegroapp A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 22150 (pool-24-thread-), pid 22037 (.aegro.aegroapp)
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG: Build fingerprint: 'google/sdk_gphone_x86/generic_x86:10/QSR1.190920.001/5891938:user/release-keys'
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG: Revision: '0'
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG: ABI: 'x86'
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG: Timestamp: 2020-11-04 10:29:00-0300
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG: pid: 22037, tid: 22150, name: pool-24-thread-  >>> com.aegro.aegroapp <<<
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG: uid: 10137
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG: signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG:     eax 00000000  ebx 00005615  ecx 00005686  edx 00000006
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG:     edi f3d0733e  esi c72d6e60
2020-11-04 10:29:00.231 22160-22160/? A/DEBUG:     ebp f5ac5ad0  esp c72d6e08  eip f5ac5ad9
2020-11-04 10:29:00.322 22160-22160/? A/DEBUG: backtrace:
2020-11-04 10:29:00.322 22160-22160/? A/DEBUG:       #00 pc 00000ad9  [vdso] (__kernel_vsyscall+9)
2020-11-04 10:29:00.322 22160-22160/? A/DEBUG:       #01 pc 00092328  /apex/com.android.runtime/lib/bionic/libc.so (syscall+40) (BuildId: 76290498408016ad14f4b98c3ab6c65c)
2020-11-04 10:29:00.322 22160-22160/? A/DEBUG:       #02 pc 000ad651  /apex/com.android.runtime/lib/bionic/libc.so (abort+193) (BuildId: 76290498408016ad14f4b98c3ab6c65c)
2020-11-04 10:29:00.322 22160-22160/? A/DEBUG:       #03 pc 00317b6e  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.322 22160-22160/? A/DEBUG:       #04 pc 00317c16  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.322 22160-22160/? A/DEBUG:       #05 pc 00317de7  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.322 22160-22160/? A/DEBUG:       #06 pc 0025c06a  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.323 22160-22160/? A/DEBUG:       #07 pc 0025bf23  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.323 22160-22160/? A/DEBUG:       #08 pc 00282188  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.323 22160-22160/? A/DEBUG:       #09 pc 001fd5e3  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.323 22160-22160/? A/DEBUG:       #10 pc 002bd759  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.323 22160-22160/? A/DEBUG:       #11 pc 0014300a  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.323 22160-22160/? A/DEBUG:       #12 pc 001f5f5f  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.323 22160-22160/? A/DEBUG:       #13 pc 002a5026  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.323 22160-22160/? A/DEBUG:       #14 pc 002a4ff0  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.323 22160-22160/? A/DEBUG:       #15 pc 00268b6c  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #16 pc 002a0826  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #17 pc 002a3106  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #18 pc 002a4029  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #19 pc 002a412f  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #20 pc 00140d60  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #21 pc 000b940b  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #22 pc 000b703b  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #23 pc 000b63a4  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #24 pc 0012ccdc  /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/lib/x86/librealm-jni.so (Java_io_realm_internal_objectstore_OsObjectBuilder_nativeCreateOrUpdateTopLevelObject+393) (BuildId: 00383e8ac38365b37446f434bc612333b860c5d4)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #25 pc 00144f67  /apex/com.android.runtime/lib/libart.so (art_quick_generic_jni_trampoline+71) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.324 22160-22160/? A/DEBUG:       #26 pc 0201ead4  /memfd:/jit-cache (deleted) (io.realm.internal.objectstore.OsObjectBuilder.updateExistingTopLevelObject+116)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #27 pc 0201db2c  /memfd:/jit-cache (deleted) (io.realm.com_aegro_aegroapp_domainDB_FarmDBRealmProxy.update+4252)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #28 pc 0013e9a2  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_static_stub+418) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #29 pc 00149a7a  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+298) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #30 pc 00332502  /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+386) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #31 pc 0032d3df  /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+719) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #32 pc 0068870f  /apex/com.android.runtime/lib/libart.so (MterpInvokeStaticRange+495) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #33 pc 00138ca1  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static_range+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #34 pc 00361f5a  [anon:dalvik-classes3.dex extracted in memory from /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/base.apk!classes3.dex] (io.realm.com_aegro_aegroapp_domainDB_FarmDBRealmProxy.copyOrUpdate+422)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #35 pc 006888f9  /apex/com.android.runtime/lib/libart.so (MterpInvokeStaticRange+985) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #36 pc 00138ca1  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static_range+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.325 22160-22160/? A/DEBUG:       #37 pc 00316b22  [anon:dalvik-classes3.dex extracted in memory from /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/base.apk!classes3.dex] (io.realm.DefaultRealmModuleMediator.copyOrUpdate+870)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #38 pc 006859f7  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtualRange+1287) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #39 pc 00138b21  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual_range+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #40 pc 00330344  [anon:dalvik-classes3.dex extracted in memory from /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/base.apk!classes3.dex] (io.realm.Realm.copyOrUpdate+80)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #41 pc 006845ac  /apex/com.android.runtime/lib/libart.so (MterpInvokeDirect+1324) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #42 pc 00138921  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_direct+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #43 pc 00330dac  [anon:dalvik-classes3.dex extracted in memory from /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/base.apk!classes3.dex] (io.realm.Realm.copyToRealmOrUpdate+120)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #44 pc 00681adc  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1612) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #45 pc 00138821  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #46 pc 003f5ffa  [anon:dalvik-classes.dex extracted in memory from /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/base.apk] (com.aegro.aegroapp.domainDB.FarmDB.saveFarms+206)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #47 pc 00684f6c  /apex/com.android.runtime/lib/libart.so (MterpInvokeStatic+1260) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #48 pc 001389a1  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.326 22160-22160/? A/DEBUG:       #49 pc 0039ee1a  [anon:dalvik-classes.dex extracted in memory from /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/base.apk] (com.aegro.aegroapp.core.facade.FarmFacade.saveFarms+18)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #50 pc 006845ac  /apex/com.android.runtime/lib/libart.so (MterpInvokeDirect+1324) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #51 pc 00138921  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_direct+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #52 pc 0039e66c  [anon:dalvik-classes.dex extracted in memory from /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/base.apk] (com.aegro.aegroapp.core.facade.FarmFacade.fetchData+92)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #53 pc 00681adc  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1612) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #54 pc 00138821  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #55 pc 003a7cb0  [anon:dalvik-classes.dex extracted in memory from /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/base.apk] (com.aegro.aegroapp.core.syncservice.sync.DownloadDataWorker.doWork+196)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #56 pc 00681adc  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1612) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #57 pc 00138821  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #58 pc 00318ef4  [anon:dalvik-classes.dex extracted in memory from /data/app/com.aegro.aegroapp-vkWj2zs_gqc925xwAOpFVQ==/base.apk] (androidx.work.Worker$1.run+4)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #59 pc 006837bc  /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1980) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #60 pc 00138a21  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.327 22160-22160/? A/DEBUG:       #61 pc 001f7fb2  /apex/com.android.runtime/javalib/core-oj.jar (java.util.concurrent.ThreadPoolExecutor.runWorker+158)
2020-11-04 10:29:00.328 22160-22160/? A/DEBUG:       #62 pc 00681adc  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1612) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.328 22160-22160/? A/DEBUG:       #63 pc 00138821  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.328 22160-22160/? A/DEBUG:       #64 pc 001f6d60  /apex/com.android.runtime/javalib/core-oj.jar (java.util.concurrent.ThreadPoolExecutor$Worker.run+4)
2020-11-04 10:29:00.328 22160-22160/? A/DEBUG:       #65 pc 006837bc  /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1980) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.328 22160-22160/? A/DEBUG:       #66 pc 00138a21  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+33) (BuildId: 895645e5113da057f27d9b2ec11eb3bf)
2020-11-04 10:29:00.328 22160-22160/? A/DEBUG:       #67 pc 000ea918  /apex/com.android.runtime/javalib/core-oj.jar (java.lang.Thread.run+8)

pvsilvestrin avatar Nov 06 '20 01:11 pvsilvestrin

Now I am working to avoid this mmap failed error and realized that the number of active versions are increasing every time a new beginTransaction() is called. Based on this statement from realm documentation:

3) You read some data from a Realm and then block the thread on a long-running operation while writing many times to the Realm on other threads. This will cause Realm to create many intermediate versions that needs to be tracked. Avoiding this scenario is a bit more tricky, but can usually be done by either either batching the writes or avoiding having the Realm open while otherwise blocking the background thread.

I suppose the number of active versions are increasing because of some query listeners active in another thread. Is it right? In other words, if I have one change listener active Realm.getDefaultInstance().addChangeListener in one thread, every time a beginTransaction is executed in another thread a new copy of realm (active version) is created? If this is true, when all these active versions are released? Even optimising the amount of transactions needed, if the active version is always increasing, at some time there will not be memory enough.

pvsilvestrin avatar Nov 06 '20 01:11 pvsilvestrin

some help here?

pvsilvestrin avatar Nov 13 '20 00:11 pvsilvestrin

@pvsilvestrin Listeners will automatically be advanced to the latest version if you are listening on a thread with a looper and not blocking the thread. So the most important thing is to ensure that you end transactions and close realms after accessing them.

In 10.0.0 we introduced the maxNumberOfActiveVersions configuration option that will trigger assertions if the selected number of version is exceeded. You can try to set that to pin point if you forget to close realms and end up with more versions than expected.

rorbech avatar Dec 01 '20 17:12 rorbech

Closing due to inactivity, but running out of memory is usually happening due to the Realm instances not being closed correctly. Like @rorbech mentioned, we have a number of debug options for this.

  • Realm.getLocalInstanceCount(..)
  • Realm.getGlobalInstanceCount(...)
  • RealmConfiguration.maxNumberOfActiveVersions

Also, there are some documentation around how to manage the Realm lifecycle:

  • https://realm.io/docs/java/latest/#closing-realms
  • https://realm.io/docs/java/latest/#realm-instance-lifecycle
  • https://realm.io/docs/java/latest/#faq-large-realm-file-size

cmelchior avatar Dec 15 '20 13:12 cmelchior