ios – Core data heavy weight migration issues with big sized data


We are facing a challenging memory issue during a Core Data heavy weight migration in our app.

Background:
We store sizable data(~250kb/record) in a Core Data entity called “Email.” We have roughly 20k records. We are loading the “Email” list using fetchedResultsController with batching. Recently, we split the another entity named “Profile” into “Profile” and “Address” entities, requiring a heavyweight migration.

The Problem:
This migration consumes an exorbitant amount of memory, causing the OS to kill our app.
Interestingly, the “Email” entity is causing the brunt of the memory usage, even though the actual migration code deals with the “Profile” entity to create “Address.” If we remove the “sizable” data from “Email” and attempt for migration then the migration is successful.

My Questions:
Is this memory consumption expected behavior? Why does the “Email” entity, seemingly unrelated to the actual migration, seem to be the main memory culprit?

How can I prevent the OS from terminating my app during migration? Are there strategies to optimize memory usage or mitigate memory pressure?

Also we are encountering a delay in loading the email list on the very first launch of app. Subsequent launches work comparatively faster. Is that related to storing bigger size data in Email entity?

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img