ios - Core Data Performance issue while Saving -
i'm using core data of nssqlitestoretype store data in ios app. need store large amount of objects database. improve performance of core data, i'm considering many considerations like:
- saving batch wise
- saving after loop ends
- clearing context manage memory
but taking time save 100k objects. please suggest me best practices improve performance of core data while saving large amounts of data.
- you should import on non-ui thread context bound directly persistent store coordinator, not child context of main contex
- you should invoke
[managedobjectcontext save]
once in every several hundreds of new objects inserted, depending on object size , graph complexity. see this answer details - you should wrap batch step 2 in
@autoreleasepool
block , reset context after save before autorelease block exited. see this answer
Comments
Post a Comment