matghazaryan/Unrealm

Problem with compaction

Closed this issue · 2 comments

Hello,

I'm trying to make a Realm Compaction (will be triggered once in a while in RELEASE app), but somehow, using Unrealm prevents such a thing.

I'm trying to make the compaction has soon as the app has launched, but a thread has already opened a Realm instance.

If I try to make the compaction without registering Realmable, it doesn't work (as expected), but if I register them correctly, they open a Realm instance on the DB and can't compact it anymore.

What's the best way to handle this case ?

Thank you !

what do you mean by saying Realm Compaction?

By either passing:

shouldCompactOnLaunch: { total, used in //custom logic for triggering compaction }

or by calling realm.writeCopy on the Realm.

Right now, even if I do either in the AppDelegate's didFinishLaunchingWithOptions, a Realm is already opened on a thread, which prevents compaction of the database. I suspect that Unrealm opens a new Realm to create the data models.

I have to do this from time to time to keep the size of the realm minimal.

Thanks !