开发者

Core data model update crashing because of low memory on iPhone

My iPhone app update has a new version 开发者_如何学JAVAof my core data store model. I am using a custom NSEntityMigrationPolicy. However with large core data stores on older iDevices (i.e. with less memory), it is crashing in the middle of the update due to low memory. What are some strategies to deal with this issue?


I haven't done a core data update so I don't have the experience to drawn from, but I suspect that the most likely cause is that the code is trying to load everything at once. I'd suggest seeing if it's possible to do the migration in batches of X records so the processing overhead is smaller.


See the Core Data Model Versioning and Data Migration Programming Guide: Multiple Passes—Dealing With Large Datasets

Basically, you do the migration in manageable chunks instead of in all one go. Before you start a migration, check available memory. If it is tight, warn the user you've go to use a slower method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜