Realm Objective‑C & Swift 0.101 – Better Dates, Memory Overhead & Crash Handling!
Realm files read or written by this version cannot be opened with previous versions of Realm. Existing files will automatically be upgraded when they are opened. Please be careful about shipping updates to your existing apps!
We’re releasing version 0.101 of Realm Objective‑C and Realm Swift today, addressing some long-standing limitations regarding date precision, memory mapping overhead, multi-process crash handling, and more.
Nanosecond Precision Dates & New File Format
NSDate properties have discarded their sub-second values, leading to some surprising behavior in apps requiring sub-second precision in dates. This release includes a new date format that’s even more precise than
NSDate, so date properties maintain their full precision.
This new property type format required an update to the overall Realm file format, meaning that Realm files read or written by this version cannot be opened with previous versions of Realm. Existing files will automatically be upgraded when they are opened, except for read-only files bundled with your app, which you can upgrade by opening them in the Realm Browser. Please be careful about shipping updates to your existing apps! 🚨
Reduced Multi-Threaded Memory Mapping Overhead
Previous versions of Realm needed to
mmap the entire file for each thread in order to preserve transaction isolation. This isolation is why Realm doesn’t have a concept of “faults” like some other persistent data frameworks.
In this version, opening a single Realm file on multiple threads now shares a single memory mapping of the file for all threads, significantly reducing the virtual memory required to work with large files.
Improved Multi-Process Crash Handling
Crashing while in the middle of a write transaction no longer blocks other processes from performing write transactions on the same file.
You’ll recall from our previous posts on Fast Inter-Process Communication and 0.91 release announcement that Darwin doesn’t support robust inter-process mutexes 😰. So we reimplemented some of Realm’s most fundamental locking mechanisms to use
fcntl(3) to emulate robust inter-process mutexes on platforms that do not support the full POSIX API for them.
This change prevents a situation where a crash in one process holding the lock, while leaving the database locked in all other processes.
We greatly improved the performance of the background worker for fine-grained notifications for complex object graphs, and the performance of refreshing a Realm (including via
autorefresh) when there are live
RLMResults objects for that Realm.
We fixed a crash when an
List object is destroyed from the wrong thread.