Search code examples
core-datamemory-managementnsarraynsmanagedobjectnsmanagedobjectid

Large array of NSManagedObjects


Application have viewcontroller with large array of objects and it has a serious memory pressure. There are a solution - store only managedObjectIds array instead of managed objects, but I'm not sure that is a most efficient way to optimize memory management because object ids is are long too. Is there any solution to reduce memory usage?


Solution

  • Because of complex filtering and sorting I use custom object(not managed object) as parent of managed object. Sorry, I forgot to mention this important detail

    You should try to move filtering and sorting to be a predicate and sortDescriptors of NSFetchRequest. Then you could use fetchBatchSize to limit the number of objects which are simultaneously fetched from the persistent store and kept in memory.