This is a total guess; the device’s memory may be getting overwhelmed.
Realm objects are lazily-loaded; meaning that when you populate a Results object with thousands of objects, the memory impact is tiny because the objects are only loaded into memory when they are used. It’s a super efficient way to handle BIG datasets.
That process only applies though, when you are working with Realm objects, filters and sorting. As soon as objects are loaded into or cast to an array, filter them using high-level Swift functions or sort them (as in your case) all of the objects get loaded into memory. So this code
starts to play nice with realm with the predicate, the sort however eliminates the lazy-loading behavior and loads all of the objects into memory. So the var tracks is not lazily loaded.
Not sure what else is going on the rest of the code but that’s a possibility (again, just a guess).
In addition to what @Jay has said, does the above mean that you’re opening a realm (the same?) multiple times? If you don’t clean after yourself every time you’ve finished with it (there isn’t an explicit close(), the realm is closed when all references to it and its objects, including observers, are gone), it’s very possible that part of the memory is never released, and at some point an allocation for the memory mapping fails.
A debug run inside Xcode will tell you if the memory is constantly growing, and when done with Instruments, can also point you to what you’re actually leaving behind.