https://kotlinlang.org logo
#realm
Title
# realm
d

dephinera

10/17/2023, 8:23 AM
Hey, guys, We’re about to integrate the Realm DB and we noticed that there isn’t an auto-close mechanism. Could you share what approaches do you take to manage the db? Do you try to close it on app close, or perhaps you’ve implemented something with a timeout?
g

Grzegorz Gajewski

10/17/2023, 8:28 AM
We chose to keep it as Singleton and never close.
The Realm
class is no longer thread-confined, so you can share a single realm across multiple threads. You no longer need to handle the realm lifecycle explicitly with calls to close
d

dephinera

10/17/2023, 8:35 AM
Could you share where is this from, please? From the documentation: > Close Realms to Prevent Memory Leaks > It’s important to close your realm instance to free resources. Failing to close realms can lead to an
OutOfMemoryError
.
d

dephinera

10/17/2023, 8:37 AM
Now I’m confused 😅
😅 1
g

Grzegorz Gajewski

10/17/2023, 8:38 AM
d

dephinera

10/17/2023, 10:12 AM
Thanks for your input!
👌 1
2 Views