Search code examples
iosswiftrealmrealm-mobile-platform

Realm Mobile Platform - in Memory


I Just found out about the realm mobile platform and think its great. I still have a problem, some time I want to get some realm for only short time and the remove/release it.

For Example: - Let say A User search for another user and open its profile (where there is a lot of information about the user). But then he leave the profile and will never look at it again (Or will not open it very frequently). So in this case the realm will keep syncing the data of this profile and it will be just a waste of bandwidth, storage, and power.

So My question is if I can have a Sync Realm in Memory, or a way I could remove the realm when it not needed (or maybe some automatic feature that will stop syncing when not opened very frequently)?


Solution

  • Synced Realms are only actively synced while your application keeps them open (that is, while there is a corresponding Realm instance). The only exception to this is that we'll continue to upload any pending changes to the server after the last reference to a given Realm was released by the application, to ensure that any writes performed make it to the server.