简体   繁体   中英

Realm iOS RAM limitation

From Realm limits: https://realm.io/docs/objc/latest/#current-limitations

"Any single Realm file cannot be larger than the amount of memory your application would be allowed to map in iOS — this changes per device, and depends on how fragmented the memory space is at that point in time (there is a radar open about this issue: rdar://17119975). If you need to store more data, you can map it over multiple Realm files."

Does it mean that a single Realm file always stored in the RAM? Or does it mean that address space should be large enough? This statement is very confusing...

Since Realm uses mmap under the hood, it currently relies upon the programs address space to have a contiguous block of unclaimed addresses larger than the size of the Realm file. This is different from the actual amount of free memory, as memory can be free d from many different parts of the address space, leaving a lot of unused memory but no large chunks of address space sufficient to mmap the Realm file.

This is talking about memory mapping, that is virtual memory using the file as backing store. In theory, an operating system could access unlimited amounts of data that way, completely independent of the amount of RAM that you have. These files are most definitely NOT kept in RAM. They take up address space, so you will be limited in a 32 bit app, but they don't take up RAM.

In practice, I have tried mapping a 1GB file and that worked without problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM