领域 iOS RAM 限制
Realm iOS RAM limitation
来自领域限制: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."
这是否意味着单个Realm 文件始终存储在RAM 中?
或者这是否意味着地址 space 应该足够大?
这个说法很迷惑...
这里说的是内存映射,也就是以文件为后备存储的虚拟内存。从理论上讲,操作系统可以通过这种方式访问无限量的数据,完全独立于您拥有的 RAM 量。这些文件绝对不会保存在 RAM 中。它们占用地址 space,因此您将被限制在 32 位应用程序中,但它们不占用 RAM。
实际上,我尝试过映射一个 1GB 的文件并且没有问题。
由于 Realm 在后台使用 mmap
,它目前依赖于程序 address space 来拥有一个连续的无人认领地址块,其大小大于 Realm 文件的大小。这与实际可用内存量不同,因为内存可以从地址 space 的许多不同部分 free
d,留下很多未使用的内存,但没有大块地址 space足以mmap
Realm文件。
来自领域限制: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."
这是否意味着单个Realm 文件始终存储在RAM 中? 或者这是否意味着地址 space 应该足够大? 这个说法很迷惑...
这里说的是内存映射,也就是以文件为后备存储的虚拟内存。从理论上讲,操作系统可以通过这种方式访问无限量的数据,完全独立于您拥有的 RAM 量。这些文件绝对不会保存在 RAM 中。它们占用地址 space,因此您将被限制在 32 位应用程序中,但它们不占用 RAM。
实际上,我尝试过映射一个 1GB 的文件并且没有问题。
由于 Realm 在后台使用 mmap
,它目前依赖于程序 address space 来拥有一个连续的无人认领地址块,其大小大于 Realm 文件的大小。这与实际可用内存量不同,因为内存可以从地址 space 的许多不同部分 free
d,留下很多未使用的内存,但没有大块地址 space足以mmap
Realm文件。