Daily iOS
Persistence

Bulk insert performance

An initial sync saves 100,000 records into Core Data, memory climbs to 1GB and the app gets killed, and the UI freezes the whole time. What do you think the causes are?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

The cause is creating 100,000 objects on the main context and saving once at the end. An NSManagedObject stays registered in the context until the save, so memory piles up, and the work is on the main queue, so the UI freezes.

Share a question