Core Data memory usage while importing large dataset

前端 未结 3 603
你的背包
你的背包 2021-02-04 16:28

I\'m now stuck for about two weeks with a nasty Core Data problem. I read lots of blogpost, articles and SO questions/answers but I\'m still not able to solve my problem.

<
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 17:06

    For every NSManagedObjectContext that you keep around for a specific purpose you are going to accumulate instances of NSManagedObject

    A NSManagedObjectContext is just a piece of scratch note paper that you can instantiate at will and save if you wish to keep changes in the NSPersistentStore and then discard afterward.

    For the parsing operations (layer 3) try creating a MOC for the op , do your parsing, save the MOC and then discard it afterwards.

    It feels like you have at least one layer of MOC being held in strong references too many.

    Basically ask the question for each of the MOC's. "Why am keeping this object and its associated children alive".

提交回复
热议问题