Best practice to use Realm Swift in Background Worker Thread?


(Rinat) #1

The sample (crashing on long-term usage) source code of the whole app is available here: https://github.com/ruuvi/com.ruuvi.station.ios/tree/dev.

Problem: Realm file grows up to 7Gb and finally crashes the app on launch.

I’ve created GitHub issue, but want to ask here as well. Any hints to fix the crashes, except for my current strategy:

you may call invalidate on Realm
use shouldCompactOnLaunch
wrap Realm usage into autoreleasepool

?


(Rinat) #2

First thing I’ve done - added Realm invalidation on daemon stop:


(Rinat) #3

Second thing - compact Realm: