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

Unregister realm and schema change callbacks when realm is GC'ed

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

      As part of #596 we have started using the C-API's realm_add_realm_changed_callback and realm_add_schema_changed_callback but these callbacks are not unregistered when the realm is garbage collected. We need to hook this up with our native reference queue/cleaner API.

      Until this is done the realm will not be closed unless explicitly closing the realm with realm.close(). To overcome this limitation in the memory test I have added an internal method to explicit release the callbacks https://github.com/realm/realm-kotlin/pull/596/files#diff-4d0528b8584520f9db14ff4031d83ca6cb837bcd889022c4abcc08b6309235baR188

      We should either generalize the NativeObjectReference/CPointerWrapper to allow managing other things than native pointer and allow overriding the clean up action to unregister the callback tokens or rely on core to align the callback registration mechanisms as filed in https://github.com/realm/realm-core/issues/5217.

            Assignee:
            claus.rorbech@mongodb.com Claus Rørbech (Inactive)
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: