Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
应用程序具有包含大量对象的视图控制器,并且它具有严重的内存压力。有一个解决方案 - 只存储 managedObjectIds 数组而不是托管对象,但我不确定这是优化内存管理的最有效方法,因为对象 ID 也很长。有没有减少内存使用的解决方案?
由于复杂的过滤和排序,我使用自定义对象(不是托管对象)作为托管对象的父对象。对不起,我忘了提这个重要的细节
您应该尝试将过滤和排序移动到 apredicate和sortDescriptorsof NSFetchRequest。然后你可以fetchBatchSize用来限制同时从持久存储中获取并保存在内存中的对象的数量。
predicate
sortDescriptors
NSFetchRequest
fetchBatchSize