How To Close Realm Opened By Realm.getdefaultinstance?
I am using realm to store and retrieve data. Usually when we open a realm to store some data we do like: Realm realm = Realm.getDefaultInstance(); realm.beginTransaction(); // Copy
Solution 1:
Doing it as a one-liners means you cannot close the Realm, so I would advice against that.
Not closing the Realm will in the best case cause you to leak memory and have a higher chance of being killed by the system if the in the background. Worst case you will see a high increase in disk usage because Realm has to keep track of all versions of opened Realm instances (due to being a MVCC database).
I would highly advice using your first pattern. For more information about controlling the Realm instances you can read this: https://realm.io/docs/java/latest/#realm-instance-lifecycle and this https://realm.io/news/threading-deep-dive/
Post a Comment for "How To Close Realm Opened By Realm.getdefaultinstance?"