Uploaded image for project: 'Realm Kotlin'
  1. Realm Kotlin
  2. RKOTLIN-614

what is the best practise to handle Realm instance

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      I got this error when I try to insert thousands of items into db. it crashed after 100+ items were inserted.

      Unable to find source-code formatter for language: kotlin. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      val realm = Realm.open(conf)
      realm.write {
        list.forEach(::copyToRealm)
      }
      
      or
      
      list.forEach {
          realm.write { copyToRealm(it) }
      }
      
      Unable to find source-code formatter for language: log. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      java.lang.IllegalArgumentException: Could not execute the write transaction: RealmCoreException([2]: mmap() failed: Out of memory size: 48971776 offset: 0)
      

      I try to write a cahce to fix this. a map with db name and call count, Realm instance will be closed after 10 write transcation then create a new one.
      it now can finish 1400+ insert but still got OOM crash then, and it's crashed at Realm.open(), not in write transcation.

      it's ok with realm-java. I don't know what i missed in document.

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: