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?
Asked
Active
Viewed 140 times
0
-
Do you use a table view or a collection view to show objects? – Arek Holko Oct 29 '13 at 11:07
-
Yes, I use table view to present these objects – Arsynth Oct 29 '13 at 12:17
-
Do you use also use the `NSFetchedResultsController`? – Arek Holko Oct 29 '13 at 12:22
-
No, just fetching objects and sorting with blocks, where sorting is related to object's childs(childs is fetching with predicates). 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 – Arsynth Oct 29 '13 at 13:04
1 Answers
1
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.

Arek Holko
- 8,966
- 4
- 28
- 46
-
Is it applicable for CoreData to use predicates and sort descriptors with blocks instead of string descriptions? – Arsynth Oct 29 '13 at 14:36
-
1@user578205: it's not possible. [Here's](http://stackoverflow.com/questions/3543208/nsfetchrequest-and-predicatewithblock) an explanation. You'll have to change them, such that they can be translated into SQL queries. – Arek Holko Oct 29 '13 at 14:40