Some of our users crash on Core Data migration.
There are already several questions about "Core Data Migration & crash", mainly about memory usage and UI response.
Migrating large Core Data database crash
Out-Of-Memory while doing Core Data migration
Core Data causing app to crash while migrating
Core Data lightweight migration crash
For high memory peak, Apple suggests multiple passes solution, and here is another large datasets solution.
When I try to reproduce the problem, like migrating large datasets using lightweight migration, Xcode will sometimes terminate my app due to memory usage. So I think that our users may come across crash due to the same reason - low memory.
But, @Marcus S. Zarra told me :
@Jason Lee: Lightweight migration doesn't run out of memory. Perhaps you are confusing it with a bad food crash or something else? I would suggest opening a new SO question and sending me the link. – Marcus S. Zarra
So I create this new question to ask:
- How to tell the reason when the app crash on Core Data Migration? Memory problem or no UI response.
- How to solve the problem?
Thanks .
UPDATE 1: add crash log
@Marcus S. Zarra , you are right. ATE BAD FOOD...
Date/Time: 2014-01-03 15:15:00.801 +0800
OS Version: iPhone OS 5.1.1 (9B206)
Report Version: 104
Exception Type: 00000020
Exception Codes: 0x8badf00d
Highlighted Thread: 0
Application Specific Information:
com.xxx.xxx failed to launch in time
Elapsed total CPU time (seconds): 7.330 (user 7.330, system 0.000), 36% CPU
Elapsed application CPU time (seconds): 4.387, 21% CPU
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsqlite3.dylib 0x317ae6ba ___lldb_unnamed_function176$$libsqlite3.dylib + 166
1 libsqlite3.dylib 0x317a2846 ___lldb_unnamed_function128$$libsqlite3.dylib + 7934
2 libsqlite3.dylib 0x317a06c2 sqlite3_step + 2098
3 CoreData 0x36924e2e _execute + 50
4 CoreData 0x36924d64 -[NSSQLiteConnection execute] + 2408
5 CoreData 0x369c7d54 -[NSSQLConnection prepareAndExecuteSQLStatement:] + 40
6 CoreData 0x36a19582 -[_NSSQLiteStoreMigrator performMigration:] + 590
7 CoreData 0x36a102b8 -[NSSQLiteInPlaceMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 1948
8 CoreData 0x369b5c02 -[NSMigrationManager migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:] + 482
9 CoreData 0x36a01bf4 -[NSStoreMigrationPolicy(InternalMethods) migrateStoreAtURL:toURL:storeType:options:withManager:error:] + 176
10 CoreData 0x36a0119c -[NSStoreMigrationPolicy migrateStoreAtURL:withManager:metadata:options:error:] + 84
11 CoreData 0x36a02b58 -[NSStoreMigrationPolicy(InternalMethods) _gatherDataAndPerformMigration:] + 2188
12 CoreData 0x3691a20e -[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:] + 3086
So, migrate the data asynchronously?