fun <T : RealmModel> RealmModel.freeze(): T

Returns a frozen snapshot of this object. The frozen copy can be read and queried from any thread without throwing an IllegalStateException.

Freezing a RealmModel also creates a frozen Realm which has its own lifecycle, but if the live Realm that spawned the original collection is fully closed (i.e. all instances across all threads are closed), the frozen Realm and object will be closed as well.

Frozen objects can be queried as normal, but trying to mutate it in any way or attempting to register a listener will throw an IllegalStateException.

Note: Keeping a large number of frozen objects with different versions alive can have a negative impact on the filesize of the Realm. In order to avoid such a situation it is possible to set io.realm.RealmConfiguration.Builder.maxNumberOfActiveVersions.


a frozen copy of this object.


if this method is called from inside a write transaction.