What is the most efficient way to delete a large number (10.000+) objects in Core Data?

后端 未结 6 1344
青春惊慌失措
青春惊慌失措 2020-12-17 01:07

The way I\'m trying to delete multiple sets of 10.000+ NSManagedObjects is just too memory intensive (around 20MB live bytes), and my app is being jettisoned. Here is the im

6条回答
  •  情歌与酒
    2020-12-17 01:59

    I have by no means tested it, but if memory is your main concern, you could try encapsulating those batches of 500 deletes in extra autorelease pool. It's possible that context:save creates quite a few autoreleased objects that don't get released until you're done with the run loop cycle. With 10 000+ records it could add up quite nicely.

提交回复
热议问题