Realm : 5.1.0
OS : Android
06-14 09:25:35.669 18336-18336/com.ehtrace.scandm.dev E/AndroidRuntime: FATAL EXCEPTION: main
io.realm.exceptions.RealmError: Unrecoverable error. mmap() failed: Out of memory size: 738197504 offset: 0 in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101
at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(Native Method)
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:319)
at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:282)
at io.realm.Realm.getInstance(Realm.java:364)
I have 2 realm databases, the first opens correctly everytime, but the second crashes sometimes after insterting ~1M entities.
The crash happens when I start the app, I try 3-4 times and then I can open and use my app.
I already checked for unclosed instances after Realm.getDefaultInstance() but they are all closed.
getGlobalInstanceCount returns 2 (because I open the 2 realm database I have).
When I download data, it's 1000 per 1000 and there are around 980 calls, after each call I insert data in Realm and commit transaction, maybe it's the problem ? Do I have to commit every X insertions or only at the end ?
may be related to #6001 but I keep it open if it's not the same problem
Affects me as well.
Realm: 5.3.0.
OS: Android.
I need to notice that it fails on the first open. getGlobalInstanceCount() returns 0. Reproducable 146% :(
The same magic number 738197504.
Large commits have to be in memory until actually committed. So if you running into memory issues making smaller commits might help, but smaller commits also have larger overhead since writing to disk is expensive. So it is a tradeoff.
However, it seems that it isn't actually inserting data that is the problem, but opening the app afterwards?
How large is your Realm file?
Hey - looks like you forgot to add a T:* label - could you please add one? :thumbsup:
This should only happen if there are tons of transactions made to insert many many items. :/
@Zhuinden What if there are ton of transactions made to insert multiple times ? What can be the other option to get rid of it ? Because the data has to be filled completely. And if the data is huge there is no option other than inserting it.
for() {
realm.executeTransaction() {
should be
realm.executeTransaction() {
for() {
I assume the above solution solved your issue. If not, feel free to re-open the issue.
Unrecoverable error. mmap() failed: Out of memory size: 738197504 offset: 0 in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 101
@ajaysharma1990 This issue is closed. Please create new issues and fill out the template.