核心数据NSInMemoryStoreType存储是否将整个图存储在内存中,因此受到系统内存的严格限制?(Will a Core Data NSInMemoryStoreType store stor

编程入门 行业动态 更新时间:2024-10-13 00:32:41
核心数据NSInMemoryStoreType存储是否将整个图存储在内存中,因此受到系统内存的严格限制?(Will a Core Data NSInMemoryStoreType store store the entire graph in memory and therefore be severely constrained by system memory?)

这可能看起来像一个明显的问题,但我的谷歌搜索没有给我一个明确的答复 - 显然, 核心数据 NSInMemoryStoreType存储的想法是将整个图存储在内存中,所以假设这将放在对任何时候可以存储的对象数量都有严格的限制 - 是这种情况吗? 或者该商店是否实施某种智能磁盘缓存方法来克服这一点? (如果有人有任何关于iOS设备提供这种容量的轶事证据,最好是iPhone 4S以上,这也是值得欢迎的)。

This might seem like an obvious question, but my Googling hasn't given me a definitive response - obviously the idea of a Core Data NSInMemoryStoreType store is to store the entire graph in memory so it would seem logical to assume that this is going to place a severe constraint on the number of objects which can be stored at any one time - is this the case? Or does this store implement some kind of intelligent disk caching method to overcome this? (And if anyone has any anecdotal evidence of the kind of capacity this gives on iOS devices, preferably iPhone 4S upwards, that would also be welcome).

最满意答案

鉴于有一个替代方案, NSBinaryStoreType ,其中数据被记录在磁盘上存储,并给出名称,我会说,假设NSInMemoryStoreType严格在内存中是安全的。

这个Apple文档说内存存储有“不需要支持”,但没有明确说没有任何东西被使用过。 它还指出SQLite“并不要求整个对象图都驻留在内存中”,这意味着其他一些类型的存储也会这样做 ,但它也不是明确的。

Bill Bumgarner(可能是负责管理iOS运行团队 Bill Bumgarner)谈论了如何使用这种类型的商店。

至于限制,一些答案是在iOS应用程序最大内存预算 ,但你应该考虑你的程序将对用户的整体体验的影响。 如果你声称所有的RAM,那么iOS会杀死其他进程,导致上下文切换时丢失上下文。 如果它使用所有的RAM,iOS在任何时候切换到Twitter或电子邮件时都会终止你的应用。 所以尽量保持在几十兆字节,不管有多少明显可用,除非你的应用程序如此真实令人惊叹,以至于没有人会离开。

Given that there is an alternative, NSBinaryStoreType, where the data is documented to be stored on disk, and given the name, I would say it is safe to assume that NSInMemoryStoreType is strictly in-memory.

This Apple doc says that there is "No backing required" for an in-memory store, but does not explicitly say that none is ever used. It also notes that SQLite "does not require that the entire object graph reside in memory", implying that some other type of store does, but again it is not explicit.

See this thread where Bill Bumgarner, presumably the Bill Bumgarner that manages the iOS runtime team, talks about how you might use this type of store.

As for the limit, some answers are in ios app maximum memory budget, but you should think about the effect your program will have on the user's overall experience. If you claim all the RAM then iOS will kill their other processes, resulting in loss of context as they switch back and forth. Also iOS will kill your app any time they switch away to do Twitter or email, if it was using all the RAM. So try to stay in the low tens of megabytes, regardless of how much is apparently available, unless your app is so truly amazing that nobody would ever switch away.

更多推荐

本文发布于:2023-07-30 16:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1338857.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内存   核心   数据   系统   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!